Skip to content

Commit 30384e0

Browse files
rafielantiga
authored andcommitted
Redis 5.0.7 support, stage 1 (#252)
* Redis 5.0.7 support, stage 1 * Redis 5.0.7: updated redismodules.h
1 parent a5194b5 commit 30384e0

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

.circleci/config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ commands:
1717
command: |
1818
./opt/readies/bin/getpy
1919
./opt/system-setup.py
20-
# git clone git://github.com/antirez/redis.git --branch 5.0.5
21-
# (cd redis && make malloc=libc -j $(nproc) && make install)
20+
git clone git://github.com/antirez/redis.git --branch 5.0.7
21+
(cd redis && make malloc=libc -j $(nproc) && make install)
22+
redis-server --version
2223
./get_deps.sh cpu
2324
- save_cache:
2425
paths:
@@ -66,13 +67,15 @@ jobs:
6667
- image: redisfab/rmbuilder:x64-buster
6768
steps:
6869
- ci_steps:
69-
platform: debian
70+
platform: debian
71+
7072
# build-macos:
7173
# macos:
7274
# xcode: 10.2.1
7375
# steps:
7476
# - ci_steps:
7577
# platform: macosx
78+
7679
build-multiarch-docker:
7780
machine:
7881
enabled: true

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# BUILD redisfab/redisai-cpu-${OSNICK}:M.m.b-${ARCH}
22

3+
ARG REDIS_VER=5.0.7
4+
35
# OSNICK=bionic|stretch|buster
46
ARG OSNICK=buster
57

@@ -10,7 +12,7 @@ ARG OS=debian:buster-slim
1012
ARG ARCH=x64
1113

1214
#----------------------------------------------------------------------------------------------
13-
FROM redisfab/redis-${ARCH}-${OSNICK}:5.0.5 AS redis
15+
FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK} AS redis
1416
FROM ${OS} AS builder
1517

1618
WORKDIR /build
@@ -38,7 +40,7 @@ RUN if [ "$TEST" = "1" ]; then make -C opt test $BUILD_ARGS NO_LFS=1; fi
3840

3941
#----------------------------------------------------------------------------------------------
4042
# FROM redis:latest
41-
FROM redisfab/redis-${ARCH}-${OSNICK}:5.0.5
43+
FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK}
4244

4345
RUN set -e; apt-get -qq update; apt-get -q install -y libgomp1
4446

src/redismodule.h

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,24 @@
8787
#define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11)
8888
/* The command was sent over the replication link. */
8989
#define REDISMODULE_CTX_FLAGS_REPLICATED (1<<12)
90-
90+
/* Redis is currently loading either from AOF or RDB. */
91+
#define REDISMODULE_CTX_FLAGS_LOADING (1<<13)
92+
/* The replica has no link with its master, note that
93+
* there is the inverse flag as well:
94+
*
95+
* REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE
96+
*
97+
* The two flags are exclusive, one or the other can be set. */
98+
#define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14)
99+
/* The replica is trying to connect with the master.
100+
* (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */
101+
#define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15)
102+
/* THe replica is receiving an RDB file from its master. */
103+
#define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16)
104+
/* The replica is online, receiving updates from its master. */
105+
#define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17)
106+
/* There is currently some background process active. */
107+
#define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18)
91108

92109
#define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */
93110
#define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */
@@ -126,12 +143,21 @@
126143

127144
#define REDISMODULE_NOT_USED(V) ((void) V)
128145

146+
/* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */
147+
#define REDISMODULE_AUX_BEFORE_RDB (1<<0)
148+
#define REDISMODULE_AUX_AFTER_RDB (1<<1)
149+
129150
/* This type represents a timer handle, and is returned when a timer is
130151
* registered and used in order to invalidate a timer. It's just a 64 bit
131152
* number, because this is how each timer is represented inside the radix tree
132153
* of timers that are going to expire, sorted by expire time. */
133154
typedef uint64_t RedisModuleTimerID;
134155

156+
/* CommandFilter Flags */
157+
158+
/* Do filter RedisModule_Call() commands initiated by module itself. */
159+
#define REDISMODULE_CMDFILTER_NOSELF (1<<0)
160+
135161
/* ------------------------- End of common defines ------------------------ */
136162

137163
#ifndef REDISMODULE_CORE
@@ -150,20 +176,25 @@ typedef struct RedisModuleBlockedClient RedisModuleBlockedClient;
150176
typedef struct RedisModuleClusterInfo RedisModuleClusterInfo;
151177
typedef struct RedisModuleDict RedisModuleDict;
152178
typedef struct RedisModuleDictIter RedisModuleDictIter;
179+
typedef struct RedisModuleCommandFilterCtx RedisModuleCommandFilterCtx;
180+
typedef struct RedisModuleCommandFilter RedisModuleCommandFilter;
153181

154182
typedef int (*RedisModuleCmdFunc)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc);
155183
typedef void (*RedisModuleDisconnectFunc)(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc);
156184
typedef int (*RedisModuleNotificationFunc)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key);
157185
typedef void *(*RedisModuleTypeLoadFunc)(RedisModuleIO *rdb, int encver);
158186
typedef void (*RedisModuleTypeSaveFunc)(RedisModuleIO *rdb, void *value);
187+
typedef int (*RedisModuleTypeAuxLoadFunc)(RedisModuleIO *rdb, int encver, int when);
188+
typedef void (*RedisModuleTypeAuxSaveFunc)(RedisModuleIO *rdb, int when);
159189
typedef void (*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString *key, void *value);
160190
typedef size_t (*RedisModuleTypeMemUsageFunc)(const void *value);
161191
typedef void (*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value);
162192
typedef void (*RedisModuleTypeFreeFunc)(void *value);
163193
typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len);
164194
typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data);
195+
typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter);
165196

166-
#define REDISMODULE_TYPE_METHOD_VERSION 1
197+
#define REDISMODULE_TYPE_METHOD_VERSION 2
167198
typedef struct RedisModuleTypeMethods {
168199
uint64_t version;
169200
RedisModuleTypeLoadFunc rdb_load;
@@ -172,6 +203,9 @@ typedef struct RedisModuleTypeMethods {
172203
RedisModuleTypeMemUsageFunc mem_usage;
173204
RedisModuleTypeDigestFunc digest;
174205
RedisModuleTypeFreeFunc free;
206+
RedisModuleTypeAuxLoadFunc aux_load;
207+
RedisModuleTypeAuxSaveFunc aux_save;
208+
int aux_save_triggers;
175209
} RedisModuleTypeMethods;
176210

177211
#define REDISMODULE_GET_API(name) \
@@ -217,6 +251,7 @@ int REDISMODULE_API_FUNC(RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx,
217251
int REDISMODULE_API_FUNC(RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, long len);
218252
void REDISMODULE_API_FUNC(RedisModule_ReplySetArrayLength)(RedisModuleCtx *ctx, long len);
219253
int REDISMODULE_API_FUNC(RedisModule_ReplyWithStringBuffer)(RedisModuleCtx *ctx, const char *buf, size_t len);
254+
int REDISMODULE_API_FUNC(RedisModule_ReplyWithCString)(RedisModuleCtx *ctx, const char *buf);
220255
int REDISMODULE_API_FUNC(RedisModule_ReplyWithString)(RedisModuleCtx *ctx, RedisModuleString *str);
221256
int REDISMODULE_API_FUNC(RedisModule_ReplyWithNull)(RedisModuleCtx *ctx);
222257
int REDISMODULE_API_FUNC(RedisModule_ReplyWithDouble)(RedisModuleCtx *ctx, double d);
@@ -278,6 +313,7 @@ int REDISMODULE_API_FUNC(RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, Re
278313
void REDISMODULE_API_FUNC(RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str);
279314
int REDISMODULE_API_FUNC(RedisModule_StringCompare)(RedisModuleString *a, RedisModuleString *b);
280315
RedisModuleCtx *REDISMODULE_API_FUNC(RedisModule_GetContextFromIO)(RedisModuleIO *io);
316+
const RedisModuleString *REDISMODULE_API_FUNC(RedisModule_GetKeyNameFromIO)(RedisModuleIO *io);
281317
long long REDISMODULE_API_FUNC(RedisModule_Milliseconds)(void);
282318
void REDISMODULE_API_FUNC(RedisModule_DigestAddStringBuffer)(RedisModuleDigest *md, unsigned char *ele, size_t len);
283319
void REDISMODULE_API_FUNC(RedisModule_DigestAddLongLong)(RedisModuleDigest *md, long long ele);
@@ -337,6 +373,13 @@ void REDISMODULE_API_FUNC(RedisModule_SetDisconnectCallback)(RedisModuleBlockedC
337373
void REDISMODULE_API_FUNC(RedisModule_SetClusterFlags)(RedisModuleCtx *ctx, uint64_t flags);
338374
int REDISMODULE_API_FUNC(RedisModule_ExportSharedAPI)(RedisModuleCtx *ctx, const char *apiname, void *func);
339375
void *REDISMODULE_API_FUNC(RedisModule_GetSharedAPI)(RedisModuleCtx *ctx, const char *apiname);
376+
RedisModuleCommandFilter *REDISMODULE_API_FUNC(RedisModule_RegisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc cb, int flags);
377+
int REDISMODULE_API_FUNC(RedisModule_UnregisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter);
378+
int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgsCount)(RedisModuleCommandFilterCtx *fctx);
379+
const RedisModuleString *REDISMODULE_API_FUNC(RedisModule_CommandFilterArgGet)(RedisModuleCommandFilterCtx *fctx, int pos);
380+
int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgInsert)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg);
381+
int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgReplace)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg);
382+
int REDISMODULE_API_FUNC(RedisModule_CommandFilterArgDelete)(RedisModuleCommandFilterCtx *fctx, int pos);
340383
#endif
341384

342385
/* This is included inline inside each Redis module. */
@@ -359,6 +402,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
359402
REDISMODULE_GET_API(ReplyWithArray);
360403
REDISMODULE_GET_API(ReplySetArrayLength);
361404
REDISMODULE_GET_API(ReplyWithStringBuffer);
405+
REDISMODULE_GET_API(ReplyWithCString);
362406
REDISMODULE_GET_API(ReplyWithString);
363407
REDISMODULE_GET_API(ReplyWithNull);
364408
REDISMODULE_GET_API(ReplyWithCallReply);
@@ -442,6 +486,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
442486
REDISMODULE_GET_API(RetainString);
443487
REDISMODULE_GET_API(StringCompare);
444488
REDISMODULE_GET_API(GetContextFromIO);
489+
REDISMODULE_GET_API(GetKeyNameFromIO);
445490
REDISMODULE_GET_API(Milliseconds);
446491
REDISMODULE_GET_API(DigestAddStringBuffer);
447492
REDISMODULE_GET_API(DigestAddLongLong);
@@ -499,6 +544,13 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
499544
REDISMODULE_GET_API(SetClusterFlags);
500545
REDISMODULE_GET_API(ExportSharedAPI);
501546
REDISMODULE_GET_API(GetSharedAPI);
547+
REDISMODULE_GET_API(RegisterCommandFilter);
548+
REDISMODULE_GET_API(UnregisterCommandFilter);
549+
REDISMODULE_GET_API(CommandFilterArgsCount);
550+
REDISMODULE_GET_API(CommandFilterArgGet);
551+
REDISMODULE_GET_API(CommandFilterArgInsert);
552+
REDISMODULE_GET_API(CommandFilterArgReplace);
553+
REDISMODULE_GET_API(CommandFilterArgDelete);
502554
#endif
503555

504556
if (RedisModule_IsModuleNameBusy && RedisModule_IsModuleNameBusy(name)) return REDISMODULE_ERR;

0 commit comments

Comments
 (0)