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

Function sentinelRedisInstanceLookupSlave

src/sentinel.cpp:1420–1441  ·  view source on GitHub ↗

Lookup a slave in a master Redis instance, by ip and port. */

Source from the content-addressed store, hash-verified

1418
1419/* Lookup a slave in a master Redis instance, by ip and port. */
1420sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
1421 sentinelRedisInstance *ri, char *slave_addr, int port)
1422{
1423 sds key;
1424 sentinelRedisInstance *slave;
1425 sentinelAddr *addr;
1426
1427 serverAssert(ri->flags & SRI_MASTER);
1428
1429 /* We need to handle a slave_addr that is potentially a hostname.
1430 * If that is the case, depending on configuration we either resolve
1431 * it and use the IP addres or fail.
1432 */
1433 addr = createSentinelAddr(slave_addr, port);
1434 if (!addr) return NULL;
1435 key = announceSentinelAddrAndPort(addr);
1436 releaseSentinelAddr(addr);
1437
1438 slave = (sentinelRedisInstance*)dictFetchValue(ri->slaves,key);
1439 sdsfree(key);
1440 return slave;
1441}
1442
1443/* Return the name of the type of the instance as a string. */
1444const char *sentinelRedisInstanceTypeStr(sentinelRedisInstance *ri) {

Callers 1

Calls 5

createSentinelAddrFunction · 0.85
releaseSentinelAddrFunction · 0.85
dictFetchValueFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected