Help us shape the future of Go! Take the 2026 Go Developer Survey

redisdb

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package redisdb adapts transient Redis Pub/Sub, not Redis Streams. Construction owns a client/subscription; messages lost while disconnected have no durable replay or acknowledgement. Queue publishes with a background context and driver bounds, independently of handler cancellation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option for queue system

func WithAddr

func WithAddr(addr string) Option

WithAddr setup the addr of redis

func WithChannel

func WithChannel(channel string) Option

WithChannel setup the channel of redis

func WithChannelSize

func WithChannelSize(size int) Option

WithChannelSize redis channel size

func WithCluster

func WithCluster() Option

WithCluster redis cluster

func WithConnectTimeout

func WithConnectTimeout(timeout time.Duration) Option

WithConnectTimeout bounds initial Redis connection validation.

func WithConnectionString

func WithConnectionString(connectionString string) Option

WithConnectionString redis connection string

func WithDB

func WithDB(db int) Option

WithDB selects the logical database for a standalone client.

func WithDebug

func WithDebug() Option

WithDebug set debug mode

func WithLogger

func WithLogger(l queue.Logger) Option

WithLogger set custom logger

func WithMasterName

func WithMasterName(masterName string) Option

WithMasterName sentinel master name

func WithPassword

func WithPassword(passwd string) Option

WithPassword redis password

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) Option

WithRequestTimeout sets how long Request waits for a published message.

func WithRunFunc

func WithRunFunc(fn func(context.Context, core.TaskMessage) error) Option

WithRunFunc setup the run func of queue

func WithSentinel

func WithSentinel() Option

WithSentinel redis sentinel

func WithSkipTLSVerify

func WithSkipTLSVerify() Option

WithSkipTLSVerify returns an Option that configures the TLS settings to skip verification of the server's certificate. This is useful for connecting to servers with self-signed certificates or when certificate verification is not required. Use this option with caution as it makes the connection susceptible to man-in-the-middle attacks.

func WithTLS

func WithTLS() Option

WithTLS returns an Option that configures the use of TLS for the connection. It sets the minimum TLS version to TLS 1.2.

func WithUsername

func WithUsername(username string) Option

WithUsername redis username

type Worker

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

Worker owns the backend client and intake resources; use its constructor.

func NewWorker

func NewWorker(opts ...Option) *Worker

NewWorker creates a new Worker instance with the provided options. It initializes a Redis client based on the options and establishes a connection to the Redis server. The Worker is responsible for subscribing to a Redis channel and receiving messages from it. It returns the created Worker instance.

func NewWorkerE

func NewWorkerE(opts ...Option) (*Worker, error)

NewWorkerE creates a worker and returns connection and configuration errors.

func (*Worker) BackendName

func (*Worker) BackendName() string

BackendName identifies Redis Pub/Sub in lifecycle events.

func (*Worker) Queue

func (w *Worker) Queue(job core.TaskMessage) error

Queue publishes encoded bytes to transient subscribers using a background context and native driver limits. Success does not guarantee subscriber receipt or handler completion; caller/handler cancellation is not propagated.

func (*Worker) QueueName

func (w *Worker) QueueName() string

QueueName returns the configured Redis channel.

func (*Worker) Request

func (w *Worker) Request() (core.TaskMessage, error)

Request a new task

func (*Worker) Run

func (w *Worker) Run(ctx context.Context, task core.TaskMessage) error

Run synchronously invokes the configured handler; it must honor ctx.

func (*Worker) Shutdown

func (w *Worker) Shutdown() error

Shutdown worker

Jump to

Keyboard shortcuts

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