Documentation
¶
Overview ¶
*
- Package redis provides functionalities for connecting and interacting with Redis,
- including client initialization, stream management, and message pushing.
Index ¶
- type Client
- func (rc *Client) Close() error
- func (rc *Client) DisableAsyncBatching()
- func (rc *Client) EnableAsyncBatching(batchSize int, batchTimeout time.Duration)
- func (rc *Client) GenerateUUIDMap(createValidKeysFunc func() map[string]interface{}) error
- func (rc *Client) ListenForCommands(startFunc, stopFunc func() error)
- func (rc *Client) PushToRedis(uuid string, max int64, data map[string]interface{}) error
- func (rc *Client) PushToRedisAsync(uuid string, max int64, data map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Client *redis.Client // Underlying Redis client. Logger *logrus.Logger // Logger for logging messages. UUIDMapper *uuid.UUIDMapper // UUIDMapper for mapping UUIDs. Configuration *configuration.Redis // Redis connection settings. PubSub *redis.PubSub // PubSub client for listening to commands. Context context.Context // Context for controlling operations. // contains filtered or unexported fields }
*
- Client encapsulates the Redis client and related configurations.
func NewClient ¶
*
- NewClient initializes and returns a new Redis client. *
- @param logger A logger instance for logging.
- @param ctx The context for client operations.
- @return A pointer to the initialized Client and an error if any occurred.
func (*Client) Close ¶
*
- Close closes the Redis client connection after synchronizing the UUID map.
- Includes timeouts to prevent blocking indefinitely during shutdown. *
- @return An error if closing fails.
func (*Client) DisableAsyncBatching ¶
func (rc *Client) DisableAsyncBatching()
*
- DisableAsyncBatching disables async batching and flushes remaining items.
func (*Client) EnableAsyncBatching ¶
*
- EnableAsyncBatching enables asynchronous batched XADD operations. *
- @param batchSize The number of records per pipeline batch.
- @param batchTimeout The maximum wait time before flushing a batch.
func (*Client) GenerateUUIDMap ¶
*
- GenerateUUIDMap verifies the current UUID mappings against the provided configurations. *
- @param createValidKeysFunc A function that generates a set of valid keys as map[string]interface{}.
- @return An error if the operation fails.
func (*Client) ListenForCommands ¶
*
- ListenForCommands subscribes to the Redis channel and listens for start and stop commands.
- Includes timeout checks to prevent blocking during shutdown. *
- @param startFunc The function to execute when a start command is received.
- @param stopFunc The function to execute when a stop command is received.
func (*Client) PushToRedis ¶
*
- PushToRedis adds data to a specified Redis stream with approximate pruning. *
- @param uuid The name of the Redis stream.
- @param max The maximum number of records to retain in the stream.
- @param data The data to be added to the stream.
- @return An error if the operation fails.
func (*Client) PushToRedisAsync ¶
*
- PushToRedisAsync enqueues a stream entry for asynchronous batched XADD. *
- @param uuid The name of the Redis stream.
- @param max The maximum number of records to retain in the stream.
- @param data The data to be added to the stream.
- @return An error if async batching is not enabled or context is canceled.
Click to show internal directories.
Click to hide internal directories.