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

Function RM_GetClientUserNameById

src/module.cpp:1963–1979  ·  view source on GitHub ↗

Return the ACL user name used by the client with the specified client ID. * Client ID can be obtained with RM_GetClientId() API. If the client does not * exist, NULL is returned and errno is set to ENOENT. If the client isn't * using an ACL user, NULL is returned and errno is set to ENOTSUP */

Source from the content-addressed store, hash-verified

1961 * exist, NULL is returned and errno is set to ENOENT. If the client isn't
1962 * using an ACL user, NULL is returned and errno is set to ENOTSUP */
1963RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) {
1964 client *client = lookupClientByID(id);
1965 if (client == NULL) {
1966 errno = ENOENT;
1967 return NULL;
1968 }
1969
1970 if (client->user == NULL) {
1971 errno = ENOTSUP;
1972 return NULL;
1973 }
1974
1975 sds name = sdsnew(client->user->name);
1976 robj *str = createObject(OBJ_STRING, name);
1977 autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str);
1978 return str;
1979}
1980
1981/* This is an helper for RM_GetClientInfoById() and other functions: given
1982 * a client, it populates the client info structure with the appropriate

Callers

nothing calls this directly

Calls 4

lookupClientByIDFunction · 0.85
sdsnewFunction · 0.85
createObjectFunction · 0.85
autoMemoryAddFunction · 0.85

Tested by

no test coverage detected