Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
27f9c810
Commit
27f9c810
authored
Apr 01, 2018
by
antirez
Browse files
Modules Cluster API: GetMyClusterID() added.
parent
19c42c90
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
27f9c810
...
@@ -3961,6 +3961,13 @@ void RM_FreeClusterNodesList(char **ids) {
...
@@ -3961,6 +3961,13 @@ void RM_FreeClusterNodesList(char **ids) {
zfree
(
ids
);
zfree
(
ids
);
}
}
/* Return this node ID (REDISMODULE_CLUSTER_ID_LEN bytes) or NULL if the cluster
* is disabled. */
const
char
*
RM_GetMyClusterID
(
void
)
{
if
(
!
server
.
cluster_enabled
)
return
NULL
;
return
server
.
cluster
->
myself
->
name
;
}
/* Populate the specified info for the node having as ID the specified 'id',
/* Populate the specified info for the node having as ID the specified 'id',
* then returns REDISMODULE_OK. Otherwise if the node ID does not exist from
* then returns REDISMODULE_OK. Otherwise if the node ID does not exist from
* the POV of this local node, REDISMODULE_ERR is returned.
* the POV of this local node, REDISMODULE_ERR is returned.
...
@@ -4557,4 +4564,5 @@ void moduleRegisterCoreAPI(void) {
...
@@ -4557,4 +4564,5 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API
(
CreateTimer
);
REGISTER_API
(
CreateTimer
);
REGISTER_API
(
StopTimer
);
REGISTER_API
(
StopTimer
);
REGISTER_API
(
GetTimerInfo
);
REGISTER_API
(
GetTimerInfo
);
REGISTER_API
(
GetMyClusterID
);
}
}
src/redismodule.h
View file @
27f9c810
...
@@ -276,6 +276,7 @@ void REDISMODULE_API_FUNC(RedisModule_FreeClusterNodesList)(char **ids);
...
@@ -276,6 +276,7 @@ void REDISMODULE_API_FUNC(RedisModule_FreeClusterNodesList)(char **ids);
RedisModuleTimerID
REDISMODULE_API_FUNC
(
RedisModule_CreateTimer
)(
RedisModuleCtx
*
ctx
,
mstime_t
period
,
RedisModuleTimerProc
callback
,
void
*
data
);
RedisModuleTimerID
REDISMODULE_API_FUNC
(
RedisModule_CreateTimer
)(
RedisModuleCtx
*
ctx
,
mstime_t
period
,
RedisModuleTimerProc
callback
,
void
*
data
);
int
REDISMODULE_API_FUNC
(
RedisModule_StopTimer
)(
RedisModuleCtx
*
ctx
,
RedisModuleTimerID
id
,
void
**
data
);
int
REDISMODULE_API_FUNC
(
RedisModule_StopTimer
)(
RedisModuleCtx
*
ctx
,
RedisModuleTimerID
id
,
void
**
data
);
int
REDISMODULE_API_FUNC
(
RedisModule_GetTimerInfo
)(
RedisModuleCtx
*
ctx
,
RedisModuleTimerID
id
,
uint64_t
*
remaining
,
void
**
data
);
int
REDISMODULE_API_FUNC
(
RedisModule_GetTimerInfo
)(
RedisModuleCtx
*
ctx
,
RedisModuleTimerID
id
,
uint64_t
*
remaining
,
void
**
data
);
const
char
*
REDISMODULE_API_FUNC
(
RM_GetMyClusterID
)(
void
);
/* Experimental APIs */
/* Experimental APIs */
#ifdef REDISMODULE_EXPERIMENTAL_API
#ifdef REDISMODULE_EXPERIMENTAL_API
...
@@ -407,6 +408,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
...
@@ -407,6 +408,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API
(
CreateTimer
);
REDISMODULE_GET_API
(
CreateTimer
);
REDISMODULE_GET_API
(
StopTimer
);
REDISMODULE_GET_API
(
StopTimer
);
REDISMODULE_GET_API
(
GetTimerInfo
);
REDISMODULE_GET_API
(
GetTimerInfo
);
REDISMODULE_GET_API
(
GetMyClusterID
);
#ifdef REDISMODULE_EXPERIMENTAL_API
#ifdef REDISMODULE_EXPERIMENTAL_API
REDISMODULE_GET_API
(
GetThreadSafeContext
);
REDISMODULE_GET_API
(
GetThreadSafeContext
);
...
@@ -420,7 +422,6 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
...
@@ -420,7 +422,6 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API
(
GetBlockedClientPrivateData
);
REDISMODULE_GET_API
(
GetBlockedClientPrivateData
);
REDISMODULE_GET_API
(
AbortBlock
);
REDISMODULE_GET_API
(
AbortBlock
);
REDISMODULE_GET_API
(
SubscribeToKeyspaceEvents
);
REDISMODULE_GET_API
(
SubscribeToKeyspaceEvents
);
#endif
#endif
if
(
RedisModule_IsModuleNameBusy
&&
RedisModule_IsModuleNameBusy
(
name
))
return
REDISMODULE_ERR
;
if
(
RedisModule_IsModuleNameBusy
&&
RedisModule_IsModuleNameBusy
(
name
))
return
REDISMODULE_ERR
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment