Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ItemState ¶
type ItemState int32
const ( // state=itemProcessing means that the work for the item has been // started but it is not yet complete. ItemProcessing ItemState = 0 ItemDone ItemState = 1 // itemFailed indicates that the work for the item failed but it's // not yet being retried ItemFailed ItemState = 2 ItemDoesNotExist ItemState = 3 )
type Work ¶
type Work[Item comparable, Why any] struct { MaxSimultaneous int // required BackoffPolicy backoff.Policy // required ThreadContext func(context.Context, map[string]string) (context.Context, func()) // required // ItemWork is required if ItemsWork is nil ItemWork func(context.Context, Item, Why) error // called to do the work in a background thread. // ItemsWork is required if ItemWork is nil // ItemsWork can return // 0 errors: all success // 1 error: applies to all items // n (matching #items) errors: errors apply to items individually ItemsWork func(context.Context, []Item, Why) []error // called to do the work in a background thread. WorkDeadline time.Duration // how long to work on all items ItemRetryDelay time.Duration // how long to wait before retrying a specific item ErrorReporter func(context.Context, error, Why) // called to report errors IsFatalError func(error) bool // called in WorkUntilDone to bail out early. ClearedUp func(context.Context, error, Why, []Item) // called when prior errors are resolved FirstWorkMessage func(context.Context, Why, Item) // called when there is work to be done NotRetryingError func(context.Context, Item, Why, error) error // called when an item will not be retried, perhaps too soon RetryingOrNot func(context.Context, bool, Item, Why) // called before ItemWork, only if previously failed ItemPreWork func(context.Context, Item, Why) error // called before doing the work ItemDone func(context.Context, Item, Why) // called on success ItemFailed func(context.Context, Item, Why, error, bool) error // called on failure ItemTimeoutError func(context.Context, Item, Why, error) error // called on timeout ItemPending func(context.Context, Item, Why) // called if will be or is being processed PreWork func(context.Context, Why, []Item) error // called before starting per-item work SpanMapItem func(context.Context, Item, Why) map[string]string // called to generated span context before calling ItemWork SpanMapItems func(context.Context, []Item, Why) map[string]string // called to generated span context before calling ItemsWork // contains filtered or unexported fields }
Work provides the parameters for the jobs to be done. Except where marked, all parameters are optional.
func (*Work[Item, Why]) Work ¶
Work makes one attempt to get things done. backgroundCtx is used for all spawned go-routines. This includes all the actual work callbacks.
func (*Work[Item, Why]) WorkUntilDone ¶
WorkUntilDone iterates calls to Work until the task is complete, a fatal error is received, or the context is cancelled. backgroundCtx is used for all spawned go-routines. This includes all the actual work callbacks.
Click to show internal directories.
Click to hide internal directories.