RedisX v0.9
A simple, light-weight Redis database client
Loading...
Searching...
No Matches
redisx-sentinel.c File Reference

Functions

RedisredisxInitSentinel (const char *serviceName, const RedisServer *serverList, int nServers)
 
int redisxSetSentinelTimeout (Redis *redis, int millis)
 
int redisxValidateSentinel (const char *serviceName, const RedisServer *serverList, int nServers)
 

Detailed Description

Date
Created on Jan 6, 2025
Author
Attila Kovacs

Functions to manage clients to high-availability Redis Sentinel server configurations.

Function Documentation

◆ redisxInitSentinel()

Redis * redisxInitSentinel ( const char *  serviceName,
const RedisServer serverList,
int  nServers 
)

Initializes a Redis client with a Sentinel configuration of alternate servers, and the default sentinel node connection timeout.

Parameters
serviceNameThe service name as registered in the Sentinel server configuration. The supplied name will be copied, not referenced, so that the value passed may be freely destroyed after the call.
serverListAn set of Sentinel servers to use to dynamically find the current master. The list itself and its contents are not referenced. Instead a deep copy will be made of it, so the list that was pased can be freely destroyed after the call.
nServersThe number of servers in the list
Returns
X_SUCCESS (0) if successful, or else an error code <0.
See also
redisxSetSentinelTimeout()
redisxInit()
redisxConnect()

References REDISX_DEFAULT_SENTINEL_TIMEOUT_MILLIS, redisxInit(), redisxValidateSentinel(), x_error(), X_SUCCESS, x_trace_null(), and xStringCopyOf().

◆ redisxSetSentinelTimeout()

int redisxSetSentinelTimeout ( Redis redis,
int  millis 
)

Changes the connection timeout for Sentinel server instances in the discovery phase. This is different from the timeout that is used for the master server, once it is discovered.

Parameters
redisThe Redis instance, which was initialized for Sentinel via redisxInitSentinel().
millis[ms] The new connection timeout or <=0 to use the default value.
Returns
X_SUCCESS (0) if successfully set sentinel connection timeout, or else X_NULL if the redis instance is NULL, or X_NO_INIT if the redis instance is not initialized for Sentinel.
See also
redisxSetSocketTimeout()
redisxInitSentinel()

References REDISX_DEFAULT_SENTINEL_TIMEOUT_MILLIS, x_error(), X_NO_INIT, and X_SUCCESS.

◆ redisxValidateSentinel()

int redisxValidateSentinel ( const char *  serviceName,
const RedisServer serverList,
int  nServers 
)

Validates a Sentinel configuration.

Parameters
serviceNameThe service name as registered in the Sentinel server configuration.
serverListAn set of Sentinel servers to use to dynamically find the current master.
nServersThe number of servers in the list
Returns
X_SUCCESS (0) if successful, or X_NAME_INVALID if the serviceName is NULL or empty, or X_NULL if the serverList is NULL, or X_SIZE_INVALID if nServers is 0 or negative, or else X_GROUP_INVALID if the first server has a NULL or empty host name.

References x_error(), X_GROUP_INVALID, X_NAME_INVALID, X_NULL, X_SIZE_INVALID, and X_SUCCESS.