Documentation
¶
Overview ¶
Package refresh models the cadence of a periodic poll: the current interval, pause and resume, and additive backoff when the server reports a rate limit. It computes durations only — it owns no timer and starts no goroutine — so the caller decides when to sleep or reschedule.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ticker ¶
type Ticker struct {
// contains filtered or unexported fields
}
Ticker tracks a poll interval that can be paused and stretched under rate limiting. It holds a base interval (the steady-state cadence) and a current interval that backoff inflates and Resume restores. A Ticker carries no synchronization and is not safe for concurrent use.
func NewTicker ¶
NewTicker returns a Ticker whose base and current interval are seconds. A non-positive seconds falls back to 30s, so a misconfigured cadence never becomes a busy loop.
func (*Ticker) BackoffRateLimit ¶
BackoffRateLimit lengthens the interval by retryAfter after a rate-limit response, so polling eases off rather than hammering a throttled server. A non-positive retryAfter doubles the current interval as a fallback. Backoff accumulates until Resume resets it.
func (*Ticker) Interval ¶
Interval returns the current poll interval, including any accumulated rate-limit backoff.