redis

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisClient

type RedisClient interface {
	Pipeline() RedisPipeliner
	Publish(ctx context.Context, channel string, message any) *redis.IntCmd
	BRPop(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd
	LLen(ctx context.Context, key string) *redis.IntCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Exists(ctx context.Context, keys ...string) *redis.IntCmd
	Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
	Keys(ctx context.Context, pattern string) *redis.StringSliceCmd
	SMembers(ctx context.Context, key string) *redis.StringSliceCmd
	Ping(ctx context.Context) *redis.StatusCmd
	Close() error
}

RedisClient is the subset of *redis.Client methods used by RedisStorage. Defined as an interface so tests can drive RedisStorage against a counterfeiter fake instead of requiring a live Redis server.

type RedisPipeliner

type RedisPipeliner interface {
	LPush(ctx context.Context, key string, values ...any) *redis.IntCmd
	Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
	SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	SRem(ctx context.Context, key string, members ...any) *redis.IntCmd
	Exec(ctx context.Context) ([]redis.Cmder, error)
}

RedisPipeliner is the subset of redis.Pipeliner methods used by RedisStorage.

type RedisStorage

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

RedisStorage implements server.Storage using Redis

func (*RedisStorage) CleanupCompletedTasks

func (s *RedisStorage) CleanupCompletedTasks() int

CleanupCompletedTasks removes completed, failed, and canceled tasks

func (*RedisStorage) CleanupTasksWithRetention

func (s *RedisStorage) CleanupTasksWithRetention(maxCompleted, maxFailed int) int

CleanupTasksWithRetention removes old completed and failed tasks while keeping specified number

func (*RedisStorage) ClearQueue

func (s *RedisStorage) ClearQueue() error

ClearQueue removes all tasks from the queue

func (*RedisStorage) CreateActiveTask

func (s *RedisStorage) CreateActiveTask(task *types.Task) error

CreateActiveTask creates a new active task

func (*RedisStorage) DeleteContext

func (s *RedisStorage) DeleteContext(contextID string) error

DeleteContext deletes all tasks for a context

func (*RedisStorage) DeleteContextAndTasks

func (s *RedisStorage) DeleteContextAndTasks(contextID string) error

DeleteContextAndTasks deletes all tasks for a context

func (*RedisStorage) DeleteTask

func (s *RedisStorage) DeleteTask(taskID string) error

DeleteTask deletes a task from dead letter queue and cleans up context mapping

func (*RedisStorage) DequeueTask

func (s *RedisStorage) DequeueTask(ctx context.Context) (*server.QueuedTask, error)

DequeueTask retrieves and removes the next task from the processing queue

func (*RedisStorage) EnqueueTask

func (s *RedisStorage) EnqueueTask(ctx context.Context, task *types.Task, requestID any) error

EnqueueTask adds a task to the processing queue

func (*RedisStorage) GetActiveTask

func (s *RedisStorage) GetActiveTask(taskID string) (*types.Task, error)

GetActiveTask retrieves an active task by ID

func (*RedisStorage) GetContexts

func (s *RedisStorage) GetContexts() []string

GetContexts returns all context IDs that have tasks

func (*RedisStorage) GetContextsWithTasks

func (s *RedisStorage) GetContextsWithTasks() []string

GetContextsWithTasks returns all context IDs that have tasks

func (*RedisStorage) GetQueueLength

func (s *RedisStorage) GetQueueLength() int

GetQueueLength returns the current number of tasks in the queue

func (*RedisStorage) GetStats

func (s *RedisStorage) GetStats() server.StorageStats

GetStats provides statistics about the storage

func (*RedisStorage) GetTask

func (s *RedisStorage) GetTask(taskID string) (*types.Task, bool)

GetTask retrieves a task by ID from dead letter queue

func (*RedisStorage) GetTaskByContextAndID

func (s *RedisStorage) GetTaskByContextAndID(contextID, taskID string) (*types.Task, bool)

GetTaskByContextAndID retrieves a task by context ID and task ID

func (*RedisStorage) ListTasks

func (s *RedisStorage) ListTasks(filter server.TaskFilter) ([]*types.Task, error)

ListTasks retrieves a list of tasks based on the provided filter

func (*RedisStorage) ListTasksByContext

func (s *RedisStorage) ListTasksByContext(contextID string, filter server.TaskFilter) ([]*types.Task, error)

ListTasksByContext retrieves tasks for a specific context

func (*RedisStorage) StoreDeadLetterTask

func (s *RedisStorage) StoreDeadLetterTask(task *types.Task) error

StoreDeadLetterTask stores a completed/failed task in the dead letter queue

func (*RedisStorage) UpdateActiveTask

func (s *RedisStorage) UpdateActiveTask(task *types.Task) error

UpdateActiveTask updates an active task's metadata

type RedisStorageFactory

type RedisStorageFactory struct{}

RedisStorageFactory implements server.StorageFactory for Redis storage

func (*RedisStorageFactory) CreateStorage

func (f *RedisStorageFactory) CreateStorage(ctx context.Context, config serverConfig.QueueConfig, logger *zap.Logger) (server.Storage, error)

CreateStorage creates a Redis storage instance

func (*RedisStorageFactory) SupportedProvider

func (f *RedisStorageFactory) SupportedProvider() string

SupportedProvider returns the provider name

func (*RedisStorageFactory) ValidateConfig

func (f *RedisStorageFactory) ValidateConfig(config serverConfig.QueueConfig) error

ValidateConfig validates the configuration for Redis storage

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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