MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelConfigSetCommand

Function sentinelConfigSetCommand

src/sentinel.cpp:3168–3216  ·  view source on GitHub ↗

SENTINEL CONFIG SET */

Source from the content-addressed store, hash-verified

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

Callers 1

sentinelCommandFunction · 0.85

Calls 11

szFromObjFunction · 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