handler

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2023 License: AGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultHandlerDeadline = 30 * time.Second
)

Variables

View Source
var (
	ErrContextHasNoJob     = errors.New("context has no Job")
	ErrNoHandlerForQueue   = errors.New("no handler for queue")
	ErrNoProcessorForQueue = errors.New("no processor configured for queue")
)

Functions

func Exec

func Exec(ctx context.Context, handler Handler) (err error)

Exec executes handler functions with a concrete time deadline

Types

type Func

type Func func(ctx context.Context) error

Func is a function that Handlers execute for every Job on a queue

type Handler

type Handler struct {
	Handle        Func
	Concurrency   int
	Deadline      time.Duration
	QueueCapacity int64
}

Handler handles jobs on a queue

func New

func New(f Func, opts ...Option) (h Handler)

New creates a new queue handler

func (*Handler) WithOptions

func (h *Handler) WithOptions(opts ...Option)

WithOptions sets one or more options on handler

type Option

type Option func(w *Handler)

Option is function that sets optional configuration for Handlers

func Concurrency

func Concurrency(c int) Option

Concurrency configures Neoq handlers to process jobs concurrently the default concurrency is the number of (v)CPUs on the machine running Neoq

func Deadline

func Deadline(d time.Duration) Option

Deadline configures handlers with a time deadline for every executed job The deadline is the amount of time that can be spent executing the handler's Func when a deadline is exceeded, the job is failed and enters its retry phase

func MaxQueueCapacity

func MaxQueueCapacity(capacity int64) Option

MaxQueueCapacity configures Handlers to enforce a maximum capacity on the queues that it handles queues that have reached capacity cause Enqueue() to block until the queue is below capacity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL