Documentation
¶
Overview ¶
Package jobqueue provides a Worker which can run registered job [Func]s by name, when a message for it is received on the underlying queue.
It provides:
- Limit on how many jobs can be run simultaneously
- Automatic message timeout extension while the job is running
- Graceful shutdown
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Log logger.StandardLogger
JobCountLimit int
PollInterval time.Duration
Extend time.Duration
QueueName string
}
Config holds all parameters needed to initialize a Worker.
type JobOption ¶
type JobOption[T any] func(*jobRegistration[T])
JobOption configures a job registration
func WithOnFailure ¶
func WithOnFailure[T any](onFailure OnFailureFn[T]) JobOption[T]
WithOnFailure sets a callback to be invoked when the job fails after max retries or returns a PermanentError The Worker only supports a single OnFailure callback for a job, multiple OnFailure options must not be provided.
type OnFailureFn ¶
OnFailureFn is the function that runs if the job never completes successfully after all retries or returns a PermanentError.
type Option ¶
type Option func(*Config)
Option modifies a Config before creating the Worker.
func WithExtend ¶
WithExtend configures the frequency running jobs are polled for completion
func WithLog ¶
func WithLog(l logger.StandardLogger) Option
func WithPollInterval ¶
func WithQueueName ¶ added in v0.2.1
WithQueueName sets the queue name for telemetry labels.
type PermanentError ¶
type PermanentError struct {
Err error
}
PermanentError signals that the operation should not be retried.
func (*PermanentError) Error ¶
func (e *PermanentError) Error() string
Error returns a string representation of the Permanent error.
func (*PermanentError) Unwrap ¶
func (e *PermanentError) Unwrap() error
Unwrap returns the wrapped error.
type Worker ¶
type Worker[T any] struct { // contains filtered or unexported fields }
func New ¶
func New[T any](q queue.Interface, ser serializer.Serializer[T], options ...Option) (*Worker[T], error)