Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NoRetry always returns false independently of the number of retries. NoRetry = func(int) bool { return false } )
Functions ¶
This section is empty.
Types ¶
type FunctionQueue ¶
type FunctionQueue struct {
// contains filtered or unexported fields
}
func NewFunctionQueue ¶
func NewFunctionQueue(queueSize uint) *FunctionQueue
NewFunctionQueue returns a FunctionQueue that will be used to execute functions in the same order they are enqueued.
func (*FunctionQueue) Enqueue ¶
func (fq *FunctionQueue) Enqueue(f func() error, waitFunc WaitFunc)
Enqueue enqueues the receiving function `f` to be executed by the function queue. Depending on the size of the function queue and the amount of functions queued, this function can block until the function queue is ready to receive more requests. If `f` returns an error, `waitFunc` will be executed and, depending on the return value of `waitFunc`, `f` will be executed again or not. The return value of `f` will not be logged and it's up to the caller to log it properly.
func (*FunctionQueue) Stop ¶ added in v1.5.0
func (fq *FunctionQueue) Stop()
Stop stops the function queue from processing the functions on the queue. If there are functions in the queue waiting for them to be processed, they won't be executed.
type WaitFunc ¶ added in v1.5.0
WaitFunc will be invoked each time a queued function has returned an error. nRetries will be set to the number of consecutive execution failures that have occurred so far. The WaitFunc must return true if execution must be retried or false if the function must be returned from the queue.