queue

package module
v0.0.0-...-da3cc26 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	Open(options map[string]any) (Queue, error)
}

Driver is a queue driver interface

type Job

type Job interface {
	// SetQueueable sets the queueable wrapper of the job
	SetQueueable(Queueable)
	// GetQueueable returns the queueable wrapper of the job
	GetQueueable() Queueable
	// GetDelay returns the delay of the job
	GetDelay() time.Duration
	// GetMaxAttempts returns the max count of attempts allowed of the job
	GetMaxAttempts() int
	// GetRetryDelay returns the delay between retries of the job
	GetRetryDelay() time.Duration
	// Handle handles the job
	Handle() error
	// Failed notifies the job that it has failed
	Failed(error)
}

Job is a job interface

type Queue

type Queue interface {
	// Name returns the queue name
	Name() string
	// Empty returns true if the queue is empty
	Empty() bool
	// Count returns the number of jobs in the queue
	Count() int64
	// Enqueue adds a job to the queue and returns the job ID
	Enqueue(job Job) (Job, bool)
	// Dequeue dequeues a job from the queue and returns the job
	Dequeue() (Job, bool)
	// Remove removes a job from the queue by ID
	Remove(job Job)
	// Ack acknowledges a job
	Ack(job Job)
	// Release releases a job back to the queue
	Release(job Job)
}

Queue is a queue interface

type Queueable

type Queueable interface {
	// GetID returns the job ID
	GetID() string
	// GetQueue returns the job queue
	GetQueue() string
	// GetPayload returns the job payload
	GetPayload() Job
	// GetAttempts returns how many times the job has been attempted
	GetAttempts() int
}

Queueable is a queueable interface, it is used to wrap a job

type Worker

type Worker interface {
	Handle(job Job)
}

Jump to

Keyboard shortcuts

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