Skip to content

Commit

Permalink
feat: truncate poll exponential backoff function to max 10s (#674)
Browse files Browse the repository at this point in the history
Related to #346 and #380

The initial exponential back off algorithm introduced in #380 was not
truncated, which could lead to very long intervals. The recent release
of hcloud-go truncated the default exponential back off algorithm to
60s:
hetznercloud/hcloud-go@fd1f46c

If we take the scenario described in #346, I think we can still reduce
the max interval value for the exponential back off algorithm to <30s.
  • Loading branch information
jooola authored and lukasmetzner committed Oct 10, 2024
1 parent 8a403d2 commit 860f4e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func CreateHcloudClient(metricsRegistry *prometheus.Registry, logger log.Logger)
}

opts = append(opts, hcloud.WithPollOpts(hcloud.PollOpts{
BackoffFunc: hcloud.ExponentialBackoff(2, time.Duration(pollingInterval)*time.Second),
BackoffFunc: hcloud.ExponentialBackoffWithOpts(hcloud.ExponentialBackoffOpts{
Base: time.Duration(pollingInterval) * time.Second,
Multiplier: 2,
Cap: 10 * time.Second,
}),
}))

return hcloud.NewClient(opts...), nil
Expand Down

0 comments on commit 860f4e9

Please sign in to comment.