Documentation
¶
Index ¶
- func NewPermanentError(err error) error
- func WithOnFailure[T any](onFailure worker.OnFailureFn[T]) worker.JobOption[T]
- type Config
- type DedupQueueConfig
- type JobQueue
- func (j *JobQueue[T]) Enqueue(ctx context.Context, name string, msg T) error
- func (j *JobQueue[T]) Register(name string, fn func(context.Context, T) error, opts ...worker.JobOption[T]) error
- func (j *JobQueue[T]) RegisterHandler(handler TaskHandler[T], opts ...worker.JobOption[T]) error
- func (j *JobQueue[T]) Start(ctx context.Context) error
- func (j *JobQueue[T]) Stop(ctx context.Context) error
- type Option
- func WithDedupQueue(cfg *DedupQueueConfig) Option
- func WithExtendDelay(extendDelay time.Duration) Option
- func WithLogger(l logger.StandardLogger) Option
- func WithMaxRetries(maxRetries uint) Option
- func WithMaxTimeout(maxTimeout time.Duration) Option
- func WithMaxWorkers(maxWorkers uint) Option
- func WithQueueProvider(provider QueueProvider) Option
- type QueueProvider
- type QueueProviderOpts
- type Service
- type TaskHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPermanentError ¶
NewPermanentError creates an error that will prevent the job queue from retrying the job
func WithOnFailure ¶
func WithOnFailure[T any](onFailure worker.OnFailureFn[T]) worker.JobOption[T]
WithOnFailure sets a callback to be invoked only when the job fails after max retries The JobQueue only supports a single OnFailure callback for a job, multiple OnFailure options must not be provided.
Types ¶
type DedupQueueConfig ¶
type JobQueue ¶
type JobQueue[T any] struct { // contains filtered or unexported fields }
func New ¶
func New[T any](name string, db *sql.DB, ser serializer.Serializer[T], opts ...Option) (*JobQueue[T], error)
func (*JobQueue[T]) RegisterHandler ¶
func (j *JobQueue[T]) RegisterHandler(handler TaskHandler[T], opts ...worker.JobOption[T]) error
type Option ¶
func WithDedupQueue ¶
func WithDedupQueue(cfg *DedupQueueConfig) Option
func WithExtendDelay ¶
func WithLogger ¶
func WithLogger(l logger.StandardLogger) Option
func WithMaxRetries ¶
func WithMaxTimeout ¶
func WithMaxWorkers ¶
func WithQueueProvider ¶
func WithQueueProvider(provider QueueProvider) Option
type QueueProvider ¶
type QueueProviderOpts ¶
type QueueProviderOpts struct {
MaxReceive int
Timeout time.Duration
Logger logger.StandardLogger
}
type Service ¶
type Service[T any] interface { Start(ctx context.Context) error Stop(ctx context.Context) error Register(name string, fn func(context.Context, T) error, opts ...worker.JobOption[T]) error RegisterHandler(handler TaskHandler[T], opts ...worker.JobOption[T]) error Enqueue(ctx context.Context, name string, msg T) error }
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
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.
|
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. |
Click to show internal directories.
Click to hide internal directories.