taskqueue

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQueueAlreadyRunning = errors.New("taskqueue: queue is already running")
	ErrQueueNotRunning     = errors.New("taskqueue: queue is not running")
	ErrNilClient           = errors.New("taskqueue: redis client is nil")
	ErrNilExecutor         = errors.New("taskqueue: task executor is nil")
	ErrEmptyQueueKey       = errors.New("taskqueue: queue key is empty")
	ErrMaxAgeTooSmall      = errors.New("taskqueue: maxAge must be greater than execTimeout")
)

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Execute(ctx context.Context, taskID string, payload Payload) error
}

type Option

type Option func(*Queue)

func WithBufferSize

func WithBufferSize(size int) Option

func WithExecTimeout

func WithExecTimeout(timeout time.Duration) Option

func WithPollInterval

func WithPollInterval(interval time.Duration) Option

func WithWorkerCount

func WithWorkerCount(count int) Option

type Payload added in v1.2.0

type Payload []byte

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func New

func New(client redis.UniversalClient, queueKey string, executor Executor, opts ...Option) (*Queue, error)

func (*Queue) Name

func (q *Queue) Name() string

func (*Queue) ProcessingCount

func (q *Queue) ProcessingCount(ctx context.Context) (int64, error)

func (*Queue) Push

func (q *Queue) Push(ctx context.Context, tasks ...Task) error

func (*Queue) QueueLength

func (q *Queue) QueueLength(ctx context.Context) (int64, error)

func (*Queue) RecoverStale

func (q *Queue) RecoverStale(ctx context.Context, maxAge time.Duration) (int, error)

func (*Queue) Start

func (q *Queue) Start(ctx context.Context) error

func (*Queue) Stop

func (q *Queue) Stop() error

type Task added in v1.2.0

type Task struct {
	ID      string
	Payload Payload
}

Jump to

Keyboard shortcuts

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