Documentation
¶
Index ¶
- Variables
- type JobBatch
- type JobChain
- type MemoryQueue
- func (q *MemoryQueue) Close() error
- func (q *MemoryQueue) DeleteFailedJob(id string) error
- func (q *MemoryQueue) GetFailedJobs() ([]contract.FailedJob, error)
- func (q *MemoryQueue) GetStats() (contract.QueueStats, error)
- func (q *MemoryQueue) Push(job contract.Job) error
- func (q *MemoryQueue) PushDelayed(job contract.Job, delay time.Duration) error
- func (q *MemoryQueue) RetryJob(id string) error
- func (q *MemoryQueue) StartWorkers(workers int)
- type RedisQueue
- func (q *RedisQueue) DeleteFailedJob(id string) error
- func (q *RedisQueue) GetFailedJobs() ([]contract.FailedJob, error)
- func (q *RedisQueue) GetStats() (contract.QueueStats, error)
- func (q *RedisQueue) Push(job contract.Job) error
- func (q *RedisQueue) PushDelayed(job contract.Job, delay time.Duration) error
- func (q *RedisQueue) RetryJob(id string) error
- func (q *RedisQueue) StartWorkers(workers int)
Constants ¶
This section is empty.
Variables ¶
var (
ErrQueueClosed = errors.New("queue is closed")
)
Functions ¶
This section is empty.
Types ¶
type JobBatch ¶
type JobBatch struct {
// contains filtered or unexported fields
}
JobBatch represents a collection of jobs to run concurrently.
type JobChain ¶
type JobChain struct {
// contains filtered or unexported fields
}
JobChain executes a series of jobs sequentially. If one fails, the chain stops.
type MemoryQueue ¶
type MemoryQueue struct {
BackoffFactor time.Duration // Custom backoff multiplier (defaults to time.Second)
// contains filtered or unexported fields
}
MemoryQueue is an in-memory, channel-backed implementation of the contract.Queue interface. It is ideal for local development, testing, and single-instance deployments.
func NewMemoryQueue ¶
func NewMemoryQueue(capacity int) *MemoryQueue
NewMemoryQueue creates a new MemoryQueue with the specified buffer capacity.
func (*MemoryQueue) Close ¶
func (q *MemoryQueue) Close() error
Close gracefully shuts down the queue and waits for workers to finish.
func (*MemoryQueue) DeleteFailedJob ¶
func (q *MemoryQueue) DeleteFailedJob(id string) error
DeleteFailedJob permanently removes a failed job by its ID.
func (*MemoryQueue) GetFailedJobs ¶
func (q *MemoryQueue) GetFailedJobs() ([]contract.FailedJob, error)
GetFailedJobs lists failed jobs in the memory queue.
func (*MemoryQueue) GetStats ¶
func (q *MemoryQueue) GetStats() (contract.QueueStats, error)
GetStats retrieves overview counters of the queue state.
func (*MemoryQueue) Push ¶
func (q *MemoryQueue) Push(job contract.Job) error
Push adds a job to the back of the queue immediately.
func (*MemoryQueue) PushDelayed ¶
PushDelayed dispatches a job to the queue, delaying execution by a set duration. In this simple memory queue, we spawn a goroutine to wait, then push.
func (*MemoryQueue) RetryJob ¶
func (q *MemoryQueue) RetryJob(id string) error
RetryJob re-queues a failed job by its ID.
func (*MemoryQueue) StartWorkers ¶
func (q *MemoryQueue) StartWorkers(workers int)
StartWorkers starts a pool of background worker goroutines to process jobs.
type RedisQueue ¶
type RedisQueue struct {
BackoffFactor time.Duration // Custom backoff multiplier (defaults to time.Second)
// contains filtered or unexported fields
}
RedisQueue implements contract.Queue using a Redis List as the backing store.
func NewRedisQueue ¶
func NewRedisQueue(addr, password string, db int, registry map[string]func() contract.Job) *RedisQueue
NewRedisQueue creates a new Redis-backed queue. registry maps job names to constructor functions so deserialization can produce the correct concrete Job type.
func (*RedisQueue) DeleteFailedJob ¶
func (q *RedisQueue) DeleteFailedJob(id string) error
DeleteFailedJob permanently removes a failed job by its ID.
func (*RedisQueue) GetFailedJobs ¶
func (q *RedisQueue) GetFailedJobs() ([]contract.FailedJob, error)
GetFailedJobs lists failed jobs in the Redis queue.
func (*RedisQueue) GetStats ¶
func (q *RedisQueue) GetStats() (contract.QueueStats, error)
GetStats retrieves overview counters of the queue state.
func (*RedisQueue) Push ¶
func (q *RedisQueue) Push(job contract.Job) error
Push serializes the job and pushes it to the head of the Redis list.
func (*RedisQueue) PushDelayed ¶
PushDelayed adds a job to a Redis Sorted Set, scored by its future execution timestamp.
func (*RedisQueue) RetryJob ¶
func (q *RedisQueue) RetryJob(id string) error
RetryJob re-queues a failed job by its ID.
func (*RedisQueue) StartWorkers ¶
func (q *RedisQueue) StartWorkers(workers int)
StartWorkers spawns N worker goroutines that each block on BRPOP, waiting for jobs.