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

Function modulePopulateReplicationInfoStructure

src/module.cpp:2019–2042  ·  view source on GitHub ↗

This is an helper for moduleFireServerEvent() and other functions: * It populates the replication info structure with the appropriate * fields depending on the version provided. If the version is not valid * then REDISMODULE_ERR is returned. Otherwise the function returns * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */

Source from the content-addressed store, hash-verified

2017 * then REDISMODULE_ERR is returned. Otherwise the function returns
2018 * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */
2019int modulePopulateReplicationInfoStructure(void *ri, int structver) {
2020 if (structver != 1) return REDISMODULE_ERR;
2021
2022 RedisModuleReplicationInfoV1 *ri1 = (RedisModuleReplicationInfoV1*)ri;
2023 memset(ri1,0,sizeof(*ri1));
2024 ri1->version = structver;
2025 ri1->master = listLength(g_pserver->masters) == 0;
2026 if (!ri1->master)
2027 {
2028 redisMaster *mi = (redisMaster*)listNodeValue(listFirst(g_pserver->masters));
2029 ri1->masterhost = (char*)(mi->masterhost? mi->masterhost: "");
2030 ri1->masterport = mi->masterport;
2031 }
2032 else
2033 {
2034 ri1->masterhost = "";
2035 ri1->masterport = -1;
2036 }
2037 ri1->repl1_offset = g_pserver->master_repl_offset;
2038 ri1->repl2_offset = g_pserver->second_replid_offset;
2039 ri1->replid1 = g_pserver->replid;
2040 ri1->replid2 = g_pserver->replid2;
2041 return REDISMODULE_OK;
2042}
2043
2044/* Return information about the client with the specified ID (that was
2045 * previously obtained via the RedisModule_GetClientId() API). If the

Callers 1

moduleFireServerEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected