redis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package redis provides a Redis-backed queue adapter with priority routing and distributed worker support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisQueueWithConfig

func NewRedisQueueWithConfig(config QueueConfig) (port.QueuePort, error)

Types

type QueueConfig

type QueueConfig struct {
	// RedisAddr is the address of a standalone Redis server (e.g. "localhost:6379").
	// Used only when Client is nil — a standalone redis.Client is created from this address.
	// For Redis Cluster or Sentinel, set Client directly instead.
	RedisAddr string

	// Client is an optional pre-configured redis.UniversalClient.
	// When set, RedisAddr is ignored. This allows passing in:
	//   - redis.NewClient() for standalone Redis
	//   - redis.NewClusterClient() for Redis Cluster
	//   - redis.NewFailoverClient() for Redis Sentinel
	//   - redis.NewUniversalClient() for auto-detection
	Client redis.UniversalClient

	QueueName     string
	QueueCapacity int
}

QueueConfig holds configuration for the Redis queue adapter.

type RedisQueue

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

RedisQueue implements port.QueuePort backed by Redis.

Supports standalone Redis, Redis Cluster, and Redis Sentinel via redis.UniversalClient.

func (*RedisQueue) Dequeue

func (rq *RedisQueue) Dequeue(ctx context.Context, priority entity.Priority) (*entity.Job, error)

func (*RedisQueue) Enqueue

func (rq *RedisQueue) Enqueue(ctx context.Context, job *entity.Job) error

func (*RedisQueue) GetDepth

func (rq *RedisQueue) GetDepth(priority entity.Priority) int

func (*RedisQueue) GetStats

func (rq *RedisQueue) GetStats() *port.QueueStats

func (*RedisQueue) Start

func (rq *RedisQueue) Start(ctx context.Context) error

func (*RedisQueue) Stop

func (rq *RedisQueue) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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