Documentation
¶
Index ¶
- Variables
- func HealthCheck(ctx context.Context, client redis.UniversalClient) error
- type Client
- func (c *Client) FlushPipeline(ctx context.Context) error
- func (c *Client) MGetBatch(ctx context.Context, keys ...string) ([]interface{}, error)
- func (c *Client) MSetBatch(ctx context.Context, pairs ...string) error
- func (c *Client) Name() string
- func (c *Client) NewLeaderElector(name string) *LeaderElector
- func (c *Client) NewLock(name string, ttl time.Duration) *Lock
- func (c *Client) NewRateLimiter() *RateLimiter
- func (c *Client) PSubscribe(ctx context.Context, pattern string, ...) (*redis.PubSub, error)
- func (c *Client) PipelineBatch(ctx context.Context, cmds ...redis.Cmder) error
- func (c *Client) Publish(ctx context.Context, channel string, message any) error
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) Subscribe(ctx context.Context, channel string, handler func(payload []byte) error) (*redis.PubSub, error)
- func (c *Client) WithLock(ctx context.Context, name string, ttl time.Duration, timeout time.Duration, ...) error
- func (c *Client) XAck(ctx context.Context, stream, group string, ids ...string) error
- func (c *Client) XAdd(ctx context.Context, stream string, values map[string]any) (string, error)
- func (c *Client) XGroupCreate(ctx context.Context, stream, group, start string) error
- func (c *Client) XRead(ctx context.Context, streams []string, ids []string, count int64, ...) ([]redis.XStream, error)
- func (c *Client) XReadGroup(ctx context.Context, group, consumer string, streams []string, ids []string, ...) ([]redis.XStream, error)
- type LeaderElector
- type Lock
- type Manager
- func (m *Manager) AddConfig(name string, cfg config.RedisConfig)
- func (m *Manager) Client() (*Client, error)
- func (m *Manager) Close(ctx context.Context) error
- func (m *Manager) Connect(ctx context.Context) error
- func (m *Manager) ConnectAndGet(ctx context.Context) (redis.UniversalClient, error)
- func (m *Manager) Connection(name string) (*Client, error)
- func (m *Manager) Default() (*Client, error)
- type RateLimiter
- type RedisProvider
Constants ¶
This section is empty.
Variables ¶
var ( ErrLockAcquisitionTimeout = errors.New("redis: lock acquisition timeout") ErrLockReleaseFailed = errors.New("redis: lock release failed") )
Functions ¶
func HealthCheck ¶
func HealthCheck(ctx context.Context, client redis.UniversalClient) error
HealthCheck verifies that the Redis client can respond to a PING.
Types ¶
type Client ¶
type Client struct {
redis.UniversalClient
// contains filtered or unexported fields
}
Client wraps the go-redis UniversalClient and adds Astra-specific advanced features.
func (*Client) FlushPipeline ¶
FlushPipeline executes any pending pipeline operations
func (*Client) NewLeaderElector ¶
func (c *Client) NewLeaderElector(name string) *LeaderElector
NewLeaderElector creates a new LeaderElector instance.
func (*Client) NewRateLimiter ¶
func (c *Client) NewRateLimiter() *RateLimiter
NewRateLimiter creates a new RateLimiter instance.
func (*Client) PSubscribe ¶
func (c *Client) PSubscribe(ctx context.Context, pattern string, handler func(channel string, payload []byte) error) (*redis.PubSub, error)
PSubscribe listens for messages on channels matching a pattern.
func (*Client) PipelineBatch ¶
PipelineBatch executes commands in a pipeline for ultra-fast performance
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, channel string, handler func(payload []byte) error) (*redis.PubSub, error)
Subscribe listens for messages on a channel and handles them with a callback.
func (*Client) WithLock ¶
func (c *Client) WithLock(ctx context.Context, name string, ttl time.Duration, timeout time.Duration, fn func(ctx context.Context) error) error
WithLock executes the given function while holding the lock. It automatically retries for the given timeout and handles release.
func (*Client) XGroupCreate ¶
XGroupCreate creates a consumer group for a stream.
type LeaderElector ¶
type LeaderElector struct {
// contains filtered or unexported fields
}
LeaderElector provides distributed leader election.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents an advanced distributed lock.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles multiple Redis connections and their lifecycle.
func NewManager ¶
func NewManager(cfg config.RedisConfig, emitter *event.Emitter) *Manager
NewManager creates a new Redis manager with the given initial config for the "default" connection.
func (*Manager) AddConfig ¶
func (m *Manager) AddConfig(name string, cfg config.RedisConfig)
AddConfig adds a named Redis configuration.
func (*Manager) ConnectAndGet ¶
ConnectAndGet is a helper to connect and return the client.
func (*Manager) Connection ¶
Connection returns a named Redis connection. It connects if not already started.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter provides rate limiting functionality.
type RedisProvider ¶
type RedisProvider struct {
engine.BaseProvider
// contains filtered or unexported fields
}
RedisProvider implements engine.Provider for Redis services.
func (*RedisProvider) Boot ¶
func (p *RedisProvider) Boot(a *engine.App) error
Boot connects to Redis, pings, and initializes Redis-backed services.