Skip to content

Commit

Permalink
Initial implementation of Sentinel support
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 11, 2024
1 parent e12f0ba commit e681a8e
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 27 deletions.
7 changes: 7 additions & 0 deletions include/redisx-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ typedef struct {
RESP *attributes; ///< Attributes from the last packet received.
} ClientPrivate;

typedef struct {
RedisServer *servers; ///< List of sentinel servers.
int nServers; ///< number of servers in list
char *serviceName; ///< Name of service (for Sentinel).
} RedisSentinel;


typedef struct {
RedisSentinel *sentinel; ///< Sentinel (high-availability) server configuration.
uint32_t addr; ///< The 32-bit inet address
int port; ///< port number (usually 6379)
int dbIndex; ///< the zero-based database index
Expand Down
10 changes: 10 additions & 0 deletions include/redisx.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ typedef struct RedisEntry {
int length; ///< Bytes in value.
} RedisEntry;

/**
* Redis server host and port specification.
*
* @sa redisxInitSentinel()
*/
typedef struct RedisServer {
char *host; ///< The hostname or IP address of the server
int port; ///< The port number or &lt;=0 to use the default 6379
} RedisServer;

/**
* \brief Structure that represents a single Redis client connection instance.
Expand Down Expand Up @@ -345,6 +354,7 @@ enum redisx_protocol redisxGetProtocol(Redis *redis);
RESP *redisxGetHelloData(Redis *redis);

Redis *redisxInit(const char *server);
Redis *redisxInitSentinel(const char *serviceName, const RedisServer *serverList, int nServers);
int redisxCheckValid(const Redis *redis);
void redisxDestroy(Redis *redis);
int redisxConnect(Redis *redis, boolean usePipeline);
Expand Down
Loading

0 comments on commit e681a8e

Please sign in to comment.