Skip to content

Commit

Permalink
Merge pull request #738 from Icinga/unify-time-duration-notation
Browse files Browse the repository at this point in the history
Unify notation of `n * time.Duration`
  • Loading branch information
julianbrost authored Apr 11, 2024
2 parents 7280916 + 5029e32 commit c76788a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type Backoff func(uint64) time.Duration
// It panics if min >= max.
func NewExponentialWithJitter(min, max time.Duration) Backoff {
if min <= 0 {
min = time.Millisecond * 100
min = 100 * time.Millisecond
}
if max <= 0 {
max = time.Second * 10
max = 10 * time.Second
}
if min >= max {
panic("max must be larger than min")
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c RetryConnector) Connect(ctx context.Context) (driver.Conn, error) {
return
},
retry.Retryable,
backoff.NewExponentialWithJitter(time.Millisecond*128, time.Minute*1),
backoff.NewExponentialWithJitter(128*time.Millisecond, 1*time.Minute),
retry.Settings{
Timeout: retry.DefaultTimeout,
OnRetryableError: func(_ time.Duration, _ uint64, err, lastErr error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (h *HA) realize(
return nil
},
retry.Retryable,
backoff.NewExponentialWithJitter(time.Millisecond*256, time.Second*3),
backoff.NewExponentialWithJitter(256*time.Millisecond, 3*time.Second),
retry.Settings{
// Intentionally no timeout is set, as we use a context with a deadline.
OnRetryableError: func(_ time.Duration, attempt uint64, err, lastErr error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingaredis/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h *Heartbeat) controller(ctx context.Context) {
// Message producer loop.
g.Go(func() error {
// We expect heartbeats every second but only read them every 3 seconds.
throttle := time.NewTicker(time.Second * 3)
throttle := time.NewTicker(3 * time.Second)
defer throttle.Stop()

for id := "$"; ; {
Expand Down

0 comments on commit c76788a

Please sign in to comment.