MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sentinelConfigSetCommand

Function sentinelConfigSetCommand

app/redis-6.2.6/src/sentinel.c:3156–3204  ·  view source on GitHub ↗

SENTINEL CONFIG SET */

Source from the content-addressed store, hash-verified

3154
3155/* SENTINEL CONFIG SET <option> */
3156void sentinelConfigSetCommand(client *c) {
3157 robj *o = c->argv[3];
3158 robj *val = c->argv[4];
3159 long long numval;
3160 int drop_conns = 0;
3161
3162 if (!strcasecmp(o->ptr, "resolve-hostnames")) {
3163 if ((numval = yesnotoi(val->ptr)) == -1) goto badfmt;
3164 sentinel.resolve_hostnames = numval;
3165 } else if (!strcasecmp(o->ptr, "announce-hostnames")) {
3166 if ((numval = yesnotoi(val->ptr)) == -1) goto badfmt;
3167 sentinel.announce_hostnames = numval;
3168 } else if (!strcasecmp(o->ptr, "announce-ip")) {
3169 if (sentinel.announce_ip) sdsfree(sentinel.announce_ip);
3170 sentinel.announce_ip = sdsnew(val->ptr);
3171 } else if (!strcasecmp(o->ptr, "announce-port")) {
3172 if (getLongLongFromObject(val, &numval) == C_ERR ||
3173 numval < 0 || numval > 65535)
3174 goto badfmt;
3175 sentinel.announce_port = numval;
3176 } else if (!strcasecmp(o->ptr, "sentinel-user")) {
3177 sdsfree(sentinel.sentinel_auth_user);
3178 sentinel.sentinel_auth_user = sdslen(val->ptr) == 0 ?
3179 NULL : sdsdup(val->ptr);
3180 drop_conns = 1;
3181 } else if (!strcasecmp(o->ptr, "sentinel-pass")) {
3182 sdsfree(sentinel.sentinel_auth_pass);
3183 sentinel.sentinel_auth_pass = sdslen(val->ptr) == 0 ?
3184 NULL : sdsdup(val->ptr);
3185 drop_conns = 1;
3186 } else {
3187 addReplyErrorFormat(c, "Invalid argument '%s' to SENTINEL CONFIG SET",
3188 (char *) o->ptr);
3189 return;
3190 }
3191
3192 sentinelFlushConfig();
3193 addReply(c, shared.ok);
3194
3195 /* Drop Sentinel connections to initiate a reconnect if needed. */
3196 if (drop_conns)
3197 sentinelDropConnections();
3198
3199 return;
3200
3201badfmt:
3202 addReplyErrorFormat(c, "Invalid value '%s' to SENTINEL CONFIG SET '%s'",
3203 (char *) val->ptr, (char *) o->ptr);
3204}
3205
3206/* SENTINEL CONFIG GET <option> */
3207void sentinelConfigGetCommand(client *c) {

Callers 1

sentinelCommandFunction · 0.85

Calls 11

strcasecmpFunction · 0.85
yesnotoiFunction · 0.85
sdsfreeFunction · 0.85
sdsnewFunction · 0.85
getLongLongFromObjectFunction · 0.85
sdslenFunction · 0.85
sdsdupFunction · 0.85
addReplyErrorFormatFunction · 0.85
sentinelFlushConfigFunction · 0.85
addReplyFunction · 0.85
sentinelDropConnectionsFunction · 0.85

Tested by

no test coverage detected