Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnOpt ¶
type ConnOpt struct {
// contains filtered or unexported fields
}
ConnOpt adapts a pooled go-redis client to asynq's RedisConnOpt interface without importing asynq. asynq.RedisClientOpt cannot express ConnMaxIdleTime, so clients built from it reuse connections that managed Redis/Valkey already idle-closed ("write: broken pipe").
func NewConnOpt ¶
func NewConnOpt(rawURL string, skipTLSVerify bool, pool ...*PoolConfig) (ConnOpt, error)
NewConnOpt builds an asynq-compatible connection option whose underlying client recycles idle connections. Each call creates a dedicated client, so an asynq consumer closing its connection does not tear down another's.
func (ConnOpt) MakeRedisClient ¶
func (o ConnOpt) MakeRedisClient() interface{}
MakeRedisClient satisfies asynq.RedisConnOpt.
type PoolConfig ¶
type PoolConfig struct {
PoolSize int
MinIdleConns int
// ConnMaxIdleTime is how long a pooled connection may sit idle before it
// is discarded instead of reused. Zero applies defaultConnMaxIdleTime;
// negative disables recycling.
ConnMaxIdleTime time.Duration
}
PoolConfig holds Redis connection pool settings.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis struct holds the Redis client and addresses of Redis instances. It supports both single-instance Redis connections and Redis Cluster setups.
func NewRedisClient ¶
func NewRedisClient(addresses []string, skipTLSVerify bool, pool ...*PoolConfig) (*Redis, error)
NewRedisClient creates a new Redis client connection based on the provided list of addresses. It automatically detects if the connection is for a single Redis instance or a Redis Cluster.
Parameters: - addresses []string: A list of Redis addresses. For a single Redis instance, provide one address. - skipTLSVerify bool: Whether to skip TLS certificate verification
Returns: - *Redis: A new Redis client wrapper. - error: An error if the provided address is invalid or connection setup fails.
func (*Redis) Client ¶
func (r *Redis) Client() redis.UniversalClient
Client returns the Redis universal client. It can be used directly for Redis operations like Get, Set, or Publish.
Returns: - redis.UniversalClient: The universal Redis client, which supports both standalone and clustered Redis instances.
func (*Redis) MakeRedisClient ¶
func (r *Redis) MakeRedisClient() interface{}
MakeRedisClient returns the Redis client interface, allowing compatibility with other packages or tools.
Returns: - interface{}: The Redis client interface.