Documentation ¶
Index ¶
Constants ¶
View Source
const ( StatusDone = "DONE" // fn finished successfully. StatusFailed = "FAILED" // all attempts failed or fn returned ErrFail. StatusPending = "PENDING" // attempts are still remaining. StatusSkipped = "SKIPPED" // fn returned ErrSkip )
Status values an item on the queue can have.
Variables ¶
View Source
var ( // ErrSkip can be returned by HandlerFn to indicate that the queued item // be skipped immediately. ErrSkip = errors.New("skip") // ErrFail can be returned by HandlerFn to indicate no further retries // should be attempted. ErrFail = errors.New("failed") )
Functions ¶
Types ¶
type Handler ¶ added in v0.2.0
type Handler interface { Handle(ctx context.Context, item Item) ([]byte, error) Sanitize(ctx context.Context, item *Item) error }
HandlerFn is invoked by the queue instance when an item is available for execution or for validation when items are being enqueued.
type HandlerFn ¶
HandlerFn implements Handler using Go native func value.
type Item ¶
type Item struct { ID string `json:"id"` Type string `json:"type"` Payload string `json:"payload"` GroupID string `json:"group_id"` Attempt int `json:"attempt"` MaxAttempts int `json:"max_attempts"` NextAttempt time.Time `json:"next_attempt"` Result string `json:"result"` }
Item represents an item on the queue.
type Options ¶
type Options struct { PollInt time.Duration FnTimeout time.Duration MaxAttempts int RetryBackoff time.Duration }
Options represents optional queue configurations.
Click to show internal directories.
Click to hide internal directories.