mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Modules: AbortBlock() API implemented.
This commit is contained in:
parent
58601c8f7d
commit
95c17c0cb2
10
src/module.c
10
src/module.c
@ -3140,6 +3140,13 @@ int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) {
|
|||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Abort a blocked client blocking operation: the client will be unblocked
|
||||||
|
* without firing the reply callback. */
|
||||||
|
int RM_AbortBlock(RedisModuleBlockedClient *bc) {
|
||||||
|
bc->reply_callback = NULL;
|
||||||
|
return RM_UnblockClient(bc,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* This function will check the moduleUnblockedClients queue in order to
|
/* This function will check the moduleUnblockedClients queue in order to
|
||||||
* call the reply callback and really unblock the client.
|
* call the reply callback and really unblock the client.
|
||||||
*
|
*
|
||||||
@ -3163,7 +3170,7 @@ void moduleHandleBlockedClients(void) {
|
|||||||
/* Release the lock during the loop, as long as we don't
|
/* Release the lock during the loop, as long as we don't
|
||||||
* touch the shared list. */
|
* touch the shared list. */
|
||||||
|
|
||||||
if (c != NULL) {
|
if (c != NULL && bc->reply_callback != NULL) {
|
||||||
RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
|
RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
|
||||||
ctx.flags |= REDISMODULE_CTX_BLOCKED_REPLY;
|
ctx.flags |= REDISMODULE_CTX_BLOCKED_REPLY;
|
||||||
ctx.blocked_privdata = bc->privdata;
|
ctx.blocked_privdata = bc->privdata;
|
||||||
@ -3545,5 +3552,6 @@ void moduleRegisterCoreAPI(void) {
|
|||||||
REGISTER_API(IsBlockedReplyRequest);
|
REGISTER_API(IsBlockedReplyRequest);
|
||||||
REGISTER_API(IsBlockedTimeoutRequest);
|
REGISTER_API(IsBlockedTimeoutRequest);
|
||||||
REGISTER_API(GetBlockedClientPrivateData);
|
REGISTER_API(GetBlockedClientPrivateData);
|
||||||
|
REGISTER_API(AbortBlock);
|
||||||
REGISTER_API(Milliseconds);
|
REGISTER_API(Milliseconds);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ The modules documentation is composed of the following files:
|
|||||||
* `INTRO.md` (this file). An overview about Redis Modules system and API. It's a good idea to start your reading here.
|
* `INTRO.md` (this file). An overview about Redis Modules system and API. It's a good idea to start your reading here.
|
||||||
* `API.md` is generated from module.c top comments of RedisMoule functions. It is a good reference in order to understand how each function works.
|
* `API.md` is generated from module.c top comments of RedisMoule functions. It is a good reference in order to understand how each function works.
|
||||||
* `TYPES.md` covers the implementation of native data types into modules.
|
* `TYPES.md` covers the implementation of native data types into modules.
|
||||||
|
* `BLOCK.md` shows how to write blocking commands that will not reply immediately, but will block the client, without blocking the Redis server, and will provide a reply whenever will be possible.
|
||||||
|
|
||||||
Redis modules make possible to extend Redis functionality using external
|
Redis modules make possible to extend Redis functionality using external
|
||||||
modules, implementing new Redis commands at a speed and with features
|
modules, implementing new Redis commands at a speed and with features
|
||||||
|
@ -200,6 +200,7 @@ int REDISMODULE_API_FUNC(RedisModule_UnblockClient)(RedisModuleBlockedClient *bc
|
|||||||
int REDISMODULE_API_FUNC(RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx);
|
int REDISMODULE_API_FUNC(RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx);
|
||||||
int REDISMODULE_API_FUNC(RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx);
|
int REDISMODULE_API_FUNC(RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx);
|
||||||
void *REDISMODULE_API_FUNC(RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx);
|
void *REDISMODULE_API_FUNC(RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx);
|
||||||
|
int REDISMODULE_API_FUNC(RedisModule_AbortBlock)(RedisModuleBlockedClient *bc);
|
||||||
long long REDISMODULE_API_FUNC(RedisModule_Milliseconds)(void);
|
long long REDISMODULE_API_FUNC(RedisModule_Milliseconds)(void);
|
||||||
|
|
||||||
/* This is included inline inside each Redis module. */
|
/* This is included inline inside each Redis module. */
|
||||||
@ -307,6 +308,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
|
|||||||
REDISMODULE_GET_API(IsBlockedReplyRequest);
|
REDISMODULE_GET_API(IsBlockedReplyRequest);
|
||||||
REDISMODULE_GET_API(IsBlockedTimeoutRequest);
|
REDISMODULE_GET_API(IsBlockedTimeoutRequest);
|
||||||
REDISMODULE_GET_API(GetBlockedClientPrivateData);
|
REDISMODULE_GET_API(GetBlockedClientPrivateData);
|
||||||
|
REDISMODULE_GET_API(AbortBlock);
|
||||||
REDISMODULE_GET_API(Milliseconds);
|
REDISMODULE_GET_API(Milliseconds);
|
||||||
|
|
||||||
RedisModule_SetModuleAttribs(ctx,name,ver,apiver);
|
RedisModule_SetModuleAttribs(ctx,name,ver,apiver);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user