metrictank: Index | Files

package clock

import ""

Package clock provides aligned tickers. An aligned ticker is a channel of time.Time "ticks" similar to time.Ticker, but the ticks are even multiples of the requested period, and are delivered as shortly as possible after the clock reaching these timestamps. For example, with period=10s, the ticker ticks shortly after the passing of a unix timestamp that is a multiple of 10s, and the values returned are always these multiples. In my testing it practically ticks about .0001 to 0.0002 seconds later due to scheduling etc, but under high load, the delta may be larger. The ticks are always the "ideal" values


Package Files


func AlignedTickLossless Uses

func AlignedTickLossless(period time.Duration) <-chan time.Time

AlignedTickLossless returns an aligned ticker that waits for slow receivers, and backfills later as necessary to publish any pending ticks, at possibly a much more aggressive schedule. (keeps ticking until fully caught up) Note: clock jumps may still result in dropped ticks.

func AlignedTickLossy Uses

func AlignedTickLossy(period time.Duration) <-chan time.Time

AlignedTickLossy returns an aligned ticker that may drop ticks (if the consumer is slow or the clock jumps forward)

Package clock imports 1 packages (graph) and is imported by 2 packages. Updated 2020-06-21. Refresh now. Tools for package owners.