clients

package
v1.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 10 Imported by: 1 module, 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

func CloseAllClients added in v1.0.1

func CloseAllClients()

CloseAllClients closes all pooled Redis clients for graceful shutdown.

func CreateDirectClient added in v1.1.0

func CreateDirectClient(endpoint *config.RedisEndpoint, addr string) (*redis.Client, error)

CreateDirectClient creates a standalone client connected directly to a specific address, inheriting credentials and TLS settings from the endpoint.

func CreateRedisClient

func CreateRedisClient(endpoint *config.RedisEndpoint) (*redis.Client, error)

CreateRedisClient creates a new standalone Redis client from an endpoint configuration.

func CreateRedisClientFromURL deprecated

func CreateRedisClientFromURL(url string, password string, db int) (*redis.Client, error)

Deprecated: Use GetRedisClient for pooled clients.

func DetectClusterMode added in v1.1.0

func DetectClusterMode(ctx context.Context, endpoint *config.RedisEndpoint) (bool, error)

DetectClusterMode connects to the endpoint and checks redis_mode.

func ForEachMaster added in v1.1.0

func ForEachMaster(ctx context.Context, endpoint *config.RedisEndpoint, fn func(ctx context.Context, client *redis.Client, addr string) error) error

ForEachMaster executes fn on each master node in a cluster. For standalone Redis, fn is called once on the single node. Errors from individual nodes are collected and returned as a combined error.

func GetRedisClient added in v1.0.1

func GetRedisClient(url string, password string, db int) (*redis.Client, error)

GetRedisClient returns a pooled standalone Redis client for the given (url, password, db) combination. The returned client must NOT be closed — it is shared and long-lived.

func GetRedisInfo

func GetRedisInfo(ctx context.Context, client redis.Cmdable, section string) (map[string]string, error)

GetRedisInfo retrieves Redis INFO command output.

func PingRedis

func PingRedis(ctx context.Context, client redis.Cmdable) error

PingRedis checks if a Redis connection is working.

func ScanAllKeys added in v1.1.0

func ScanAllKeys(ctx context.Context, endpoint *config.RedisEndpoint, pattern string, maxKeys int) ([]string, error)

ScanAllKeys scans keys matching pattern across all master nodes in a cluster, or on the single node for standalone Redis. Returns deduplicated keys.

func TLSConfig added in v1.1.22

func TLSConfig(base *tls.Config, endpointInsecureSkipVerify bool) *tls.Config

TLSConfig returns the TLS settings for a rediss:// connection. It starts from a copy of base, as set by redis.ParseURL (ServerName and the skip_verify URL parameter), and keeps the system certificate pool, so a CA mounted via SSL_CERT_DIR is trusted. Verification is skipped if the URL, the endpoint or STEADYBIT_EXTENSION_INSECURE_SKIP_VERIFY asks for it.

Types

type ClusterNodeInfo added in v1.1.0

type ClusterNodeInfo struct {
	ID    string
	Addr  string // host:port
	Role  string // "master" or "slave"
	Flags string
}

ClusterNodeInfo represents a node parsed from CLUSTER NODES output.

func GetMasterNodes added in v1.1.0

func GetMasterNodes(ctx context.Context, endpoint *config.RedisEndpoint) ([]ClusterNodeInfo, bool, error)

GetMasterNodes returns ClusterNodeInfo for each master in the cluster. For standalone endpoints it returns a single entry for the configured endpoint.

func ParseClusterNodes added in v1.1.0

func ParseClusterNodes(ctx context.Context, client *redis.Client) ([]ClusterNodeInfo, error)

ParseClusterNodes runs CLUSTER NODES and parses the output.

Jump to

Keyboard shortcuts

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