MCPcopy Index your code
hub / github.com/coder/coder / nextTick

Function nextTick

enterprise/coderd/usage/cron.go:199–207  ·  view source on GitHub ↗

nextTick computes the delay until the next epoch-aligned boundary for the given interval, plus a random jitter in [0, jitter). It returns the target boundary and the total delay from now.

(now time.Time, interval, jitter time.Duration)

Source from the content-addressed store, hash-verified

197// for the given interval, plus a random jitter in [0, jitter). It
198// returns the target boundary and the total delay from now.
199func nextTick(now time.Time, interval, jitter time.Duration) (boundary time.Time, delay time.Duration) {
200 boundary = nextBoundary(now, interval)
201 delay = boundary.Sub(now)
202 if jitter > 0 {
203 //nolint:gosec // Jitter does not need cryptographic randomness.
204 delay += time.Duration(rand.Int63n(int64(jitter)))
205 }
206 return boundary, delay
207}
208
209// nextBoundary returns the first multiple of interval (relative to
210// epoch) that is strictly after t.

Callers 2

TestNextTickFunction · 0.85
runMethod · 0.85

Calls 2

nextBoundaryFunction · 0.85
DurationMethod · 0.80

Tested by 1

TestNextTickFunction · 0.68