Skip to content

Commit

Permalink
service/scheduler: schedule, rename retryInitialInterval to RetryWait
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatczuk committed Dec 27, 2021
1 parent 5cdbc1e commit 32b9416
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions pkg/service/scheduler/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func backoff(t *Task) retry.Backoff {
if t.Sched.NumRetries == 0 {
return nil
}
interval := t.Sched.RetryInitialInterval
if interval == 0 {
interval = duration.Duration(10 * time.Minute)
w := t.Sched.RetryWait
if w == 0 {
w = duration.Duration(10 * time.Minute)
}

b := retry.NewExponentialBackoff(interval.Duration(), 0, 0, 2, 0)
b := retry.NewExponentialBackoff(w.Duration(), 0, 0, 2, 0)
b = retry.WithMaxRetries(b, uint64(t.Sched.NumRetries))
return b
}
10 changes: 5 additions & 5 deletions pkg/service/scheduler/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func (t *TaskType) UnmarshalText(text []byte) error {
type Schedule struct {
gocqlx.UDT

Cron Cron `json:"cron"`
StartDate time.Time `json:"start_date"`
Interval duration.Duration `json:"interval" db:"interval_seconds"`
NumRetries int `json:"num_retries"`
RetryInitialInterval duration.Duration `json:"retry_initial_interval"`
Cron Cron `json:"cron"`
StartDate time.Time `json:"start_date"`
Interval duration.Duration `json:"interval" db:"interval_seconds"`
NumRetries int `json:"num_retries"`
RetryWait duration.Duration `json:"retry_wait"`
}

func (s Schedule) trigger() scheduler.Trigger {
Expand Down
10 changes: 5 additions & 5 deletions pkg/service/scheduler/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func TestServiceScheduleIntegration(t *testing.T) {
Print("Given: task scheduled in future")
task := h.makeTaskWithStartDate(future)
task.Sched.NumRetries = 1
task.Sched.RetryInitialInterval = duration.Duration(10 * time.Millisecond)
task.Sched.RetryWait = duration.Duration(10 * time.Millisecond)
if err := h.service.PutTask(ctx, task); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestServiceScheduleIntegration(t *testing.T) {
Print("When: task is scheduled with retry once")
task := h.makeTaskWithStartDate(now())
task.Sched.NumRetries = 1
task.Sched.RetryInitialInterval = duration.Duration(10 * time.Millisecond)
task.Sched.RetryWait = duration.Duration(10 * time.Millisecond)
if err := h.service.PutTask(ctx, task); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -563,9 +563,9 @@ func TestServiceScheduleIntegration(t *testing.T) {

Print("When: task is scheduled with retry once")
task := h.makeTask(scheduler.Schedule{
StartDate: now(),
NumRetries: 1,
RetryInitialInterval: duration.Duration(10 * time.Millisecond),
StartDate: now(),
NumRetries: 1,
RetryWait: duration.Duration(10 * time.Millisecond),
})
if err := h.service.PutTask(ctx, task); err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion schema/v3.0.0.cql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALTER TYPE schedule ADD cron text;
ALTER TYPE schedule ADD retry_initial_interval bigint;
ALTER TYPE schedule ADD retry_wait bigint;

-- CALL rewriteHealthCheck30;

0 comments on commit 32b9416

Please sign in to comment.