Commit 8525f6ab authored by Brandon Forster's avatar Brandon Forster Committed by Trevor Conn

#1444: Updated scheduler to properly use runOnce intervals.

Signed-off-by: default avatarBrandon Forster <brandonforster@gmail.com>
parent 0912bde5
......@@ -68,12 +68,6 @@ func addNewInterval(interval contract.Interval) (string, error) {
}
}
// Validate that interval is not in queue
ret, err = scClient.QueryIntervalByName(name)
if err == nil && ret.Name == name {
return "", errors.NewErrIntervalNameInUse(name)
}
// Add the new interval to the database
ID, err := dbClient.AddInterval(interval)
if err != nil {
......
......@@ -119,7 +119,6 @@ func intervalHandler(w http.ResponseWriter, r *http.Request) {
err := dec.Decode(&interval)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
LoggingClient.Error("Error decoding interval" + err.Error())
return
......@@ -333,7 +332,6 @@ func intervalActionHandler(w http.ResponseWriter, r *http.Request) {
err := dec.Decode(&intervalAction)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
LoggingClient.Error("error decoding intervalAction" + err.Error())
return
......
......@@ -69,7 +69,9 @@ func (sc *IntervalContext) Reset(interval models.Interval) {
//frequency and next time
nowBenchmark := time.Now().Unix()
sc.Frequency = parseFrequency(sc.Interval.Frequency)
if !sc.Interval.RunOnce {
sc.Frequency = parseFrequency(sc.Interval.Frequency)
}
sc.NextTime = sc.StartTime
if sc.StartTime.Unix() <= nowBenchmark && !sc.Interval.RunOnce {
......@@ -117,10 +119,13 @@ func parseFrequency(durationStr string) time.Duration {
minutes := parseInt64(matches[5])
seconds := parseInt64(matches[6])
hour := int64(time.Hour)
minute := int64(time.Minute)
second := int64(time.Second)
return time.Duration(years*24*365*hour + months*30*24*hour + days*24*hour + hours*hour + minutes*minute + seconds*second)
minute := int64(time.Minute)
hour := int64(time.Hour)
day := int64(24 * hour)
month := int64(30 * day)
year := int64(365 * day)
return time.Duration(years*year + months*month + days*day + hours*hour + minutes*minute + seconds*second)
}
func parseInt64(value string) int64 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment