Documentation ¶
Index ¶
Constants ¶
const ( // These constants are used for a Waiter to inform the TickerQueue whether to // run again or not. TryAgain = false DontTryAgain = true )
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type TickerQueue ¶
type TickerQueue struct {
// contains filtered or unexported fields
}
TickerQueue is a Waiter manager that checks a function periodically until DontTryAgain is indicated.
func NewTickerQueue ¶
func NewTickerQueue(recheckInterval time.Duration) *TickerQueue
NewTickerQueue is the constructor for a new TickerQueue.
func (*TickerQueue) Run ¶
func (w *TickerQueue) Run(ctx context.Context)
Run runs the primary wait loop until the context is canceled.
func (*TickerQueue) Wait ¶
func (w *TickerQueue) Wait(settings *Waiter)
Wait attempts to run the (*Waiter).TryFunc until either 1) the function returns the value DontTryAgain, or 2) the function's Expiration time has passed. In the case of 2, the (*Waiter).ExpireFunc will be run.
type Waiter ¶
type Waiter struct { // Expiration time is checked after the function returns TryAgain. If the // current time > Expiration, ExpireFunc will be run and the waiter will be // un-queued. Expiration time.Time // TryFunc is the function to run every recheckInterval until DontTryAgain is // returned or Waiter expires. TryFunc func() bool // ExpireFunc is a function to run in the case that the Waiter expires. ExpireFunc func() }
Waiter is a function to run every recheckInterval until completion or expiration. Completion is indicated when the TryFunc returns DontTryAgain. Expiration occurs when TryAgain is returned after Expiration time.