Documentation ¶
Overview ¶
Package worker provides worker processes
Package worker provides worker processes ¶
Package worker provides worker processes ¶
Package worker provides worker processes
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue interface { Start(ctx context.Context) (<-chan error, error) Push(ctx context.Context, job JobFunc) error Pop(ctx context.Context) (JobFunc, error) Len() uint64 }
Queue represents the interface of queue.
func NewQueue ¶
func NewQueue(opts ...QueueOption) (Queue, error)
NewQueue returns Queue if no error is occurred.
type QueueOption ¶
type QueueOption func(q *queue) error
QueueOption represents the functional option for queue.
func WithQueueBuffer ¶
func WithQueueBuffer(buffer int) QueueOption
WithQueueBuffer returns the option to set the buffer for queue.
func WithQueueCheckDuration ¶ added in v0.0.30
func WithQueueCheckDuration(dur string) QueueOption
WithQueueCheckDuration returns the option to set the qcdur for queue. If dur is invalid string, it returns errror.
func WithQueueErrGroup ¶
func WithQueueErrGroup(eg errgroup.Group) QueueOption
WithQueueErrGroup returns the options to set the eg for queue.
type Worker ¶
type Worker interface { Start(ctx context.Context) (<-chan error, error) Pause() Resume() IsRunning() bool Name() string Len() uint64 TotalRequested() uint64 TotalCompleted() uint64 Dispatch(ctx context.Context, f JobFunc) error }
Worker represents the worker interface to execute jobs.
func New ¶
func New(opts ...WorkerOption) (Worker, error)
New initializes and return the worker, or return initialization error if occurred.
type WorkerOption ¶
type WorkerOption func(w *worker) error
func WithErrGroup ¶
func WithErrGroup(eg errgroup.Group) WorkerOption
func WithLimitation ¶
func WithLimitation(limit int) WorkerOption
func WithName ¶
func WithName(name string) WorkerOption
func WithQueueOption ¶ added in v0.0.30
func WithQueueOption(opts ...QueueOption) WorkerOption
Click to show internal directories.
Click to hide internal directories.