Skip to content

Commit 1c6c933

Browse files
committed
Update the headers to the latest state.
1 parent 6472bc4 commit 1c6c933

File tree

7 files changed

+168
-40
lines changed

7 files changed

+168
-40
lines changed

build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn main() {
4242
// tricks that we need to complete the build.
4343

4444
const EXPERIMENTAL_API: &str = "REDISMODULE_EXPERIMENTAL_API";
45+
const RLEC_API: &str = "REDISMODULE_RLEC";
4546

4647
let mut build = cc::Build::new();
4748

@@ -55,7 +56,9 @@ fn main() {
5556

5657
let bindings = bindings_generator
5758
.clang_arg(format!("-D{EXPERIMENTAL_API}"))
59+
.clang_arg(format!("-D{RLEC_API}"))
5860
.header("src/include/redismodule.h")
61+
.header("src/include/redismodule-rlec.h")
5962
.allowlist_var("(REDIS|Redis).*")
6063
.blocklist_type("__darwin_.*")
6164
.allowlist_type("RedisModule.*")

redismodule-rs-macros-internals/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn api(item: TokenStream) -> TokenStream {
143143
} else if #[cfg(any(#(#all_upper_features, )*))] {
144144
#new_ver_func
145145
} else {
146-
compile_error!("min-redis-compatibility-version is not set correctly")
146+
compile_error!("Cannot generate the api! macro code. The \"min-redis-compatibility-version\" feature is not set up correctly")
147147
}
148148
}
149149
};

src/include/redismodule-rlec.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
#pragma once
3+
4+
// clang-format off
5+
6+
#include <sys/types.h>
7+
#include <stdint.h>
8+
#include <stdio.h>
9+
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
//---------------------------------------------------------------------------------------------
15+
// bigredis extensions
16+
17+
#define REDISMODULE_METADATA_NOT_ON_SWAP 0x80
18+
19+
/* Notification that a key's value is added to ram (from swap or otherwise).
20+
* swap_key_flags has 4 bits that the module can write / read.
21+
* when swap_key_metadata is NOT_ON_SWAP, it means the key is not loaded from swap. */
22+
typedef void (*RedisModuleTypeKeyAddedToDbDictFunc)(RedisModuleCtx *ctx, RedisModuleString *key, void *value, int swap_key_metadata);
23+
24+
/* Notification that a key's value is removed from ram (may still exist on swap).
25+
* when swap_key_metadata is NOT_ON_SWAP it means the key does not exist on swap.
26+
* return swap_key_metadata or NOT_ON_SWAP if key is to be deleted (and not to be written). */
27+
typedef int (*RedisModuleTypeRemovingKeyFromDbDictFunc)(RedisModuleCtx *ctx, RedisModuleString *key, void *value, int swap_key_metadata, int writing_to_swap);
28+
29+
/* return swap_key_metadata, 0 indicates nothing to write. when out_min_expire is -1 it indicates nothing to write. */
30+
typedef int (*RedisModuleTypeGetKeyMetadataForRdbFunc)(RedisModuleCtx *ctx, RedisModuleString *key, void *value, long long *out_min_expire, long long *out_max_expire);
31+
32+
#define REDISMODULE_TYPE_EXT_METHOD_VERSION 1
33+
typedef struct RedisModuleTypeExtMethods {
34+
uint64_t version;
35+
RedisModuleTypeKeyAddedToDbDictFunc key_added_to_db_dict;
36+
RedisModuleTypeRemovingKeyFromDbDictFunc removing_key_from_db_dict;
37+
RedisModuleTypeGetKeyMetadataForRdbFunc get_key_metadata_for_rdb;
38+
} RedisModuleTypeExtMethods;
39+
40+
typedef void (*RedisModuleSwapPrefetchCB)(RedisModuleCtx *ctx, RedisModuleString *key, void* user_data);
41+
42+
/* APIs */
43+
44+
REDISMODULE_API int (*RedisModule_SetDataTypeExtensions)(RedisModuleCtx *ctx, RedisModuleType *mt, RedisModuleTypeExtMethods *typemethods) REDISMODULE_ATTR;
45+
REDISMODULE_API int (*RedisModule_SwapPrefetchKey)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleSwapPrefetchCB fn, void *user_data, int flags) REDISMODULE_ATTR;
46+
REDISMODULE_API int (*RedisModule_GetSwapKeyMetadata)(RedisModuleCtx *ctx, RedisModuleString *key) REDISMODULE_ATTR;
47+
REDISMODULE_API int (*RedisModule_SetSwapKeyMetadata)(RedisModuleCtx *ctx, RedisModuleString *key, int module_metadata) REDISMODULE_ATTR;
48+
REDISMODULE_API int (*RedisModule_IsKeyInRam)(RedisModuleCtx *ctx, RedisModuleString *key) REDISMODULE_ATTR;
49+
50+
//---------------------------------------------------------------------------------------------
51+
52+
/* Keyspace changes notification classes. Every class is associated with a
53+
* character for configuration purposes.
54+
* NOTE: These have to be in sync with NOTIFY_* in server.h */
55+
56+
#define REDISMODULE_NOTIFY_TRIMMED (1<<30) /* trimmed by reshard trimming enterprise only event */
57+
58+
/* Server events definitions.
59+
* Those flags should not be used directly by the module, instead
60+
* the module should use RedisModuleEvent_* variables */
61+
62+
#define REDISMODULE_EVENT_SHARDING 1000
63+
64+
static const RedisModuleEvent
65+
RedisModuleEvent_Sharding = {
66+
REDISMODULE_EVENT_SHARDING,
67+
1
68+
};
69+
70+
/* Those are values that are used for the 'subevent' callback argument. */
71+
72+
#define REDISMODULE_SUBEVENT_SHARDING_SLOT_RANGE_CHANGED 0
73+
#define REDISMODULE_SUBEVENT_SHARDING_TRIMMING_STARTED 1
74+
#define REDISMODULE_SUBEVENT_SHARDING_TRIMMING_ENDED 2
75+
76+
/* APIs */
77+
78+
REDISMODULE_API int (*RedisModule_ShardingGetKeySlot)(RedisModuleString *keyname) REDISMODULE_ATTR;
79+
REDISMODULE_API void (*RedisModule_ShardingGetSlotRange)(int *first_slot, int *last_slot) REDISMODULE_ATTR;
80+
81+
//---------------------------------------------------------------------------------------------
82+
83+
#define REDISMODULE_RLEC_API_DEFS \
84+
REDISMODULE_GET_API(ShardingGetKeySlot); \
85+
REDISMODULE_GET_API(ShardingGetSlotRange); \
86+
REDISMODULE_GET_API(SetDataTypeExtensions); \
87+
REDISMODULE_GET_API(SwapPrefetchKey); \
88+
REDISMODULE_GET_API(GetSwapKeyMetadata); \
89+
REDISMODULE_GET_API(SetSwapKeyMetadata); \
90+
REDISMODULE_GET_API(IsKeyInRam); \
91+
/**/
92+
93+
//---------------------------------------------------------------------------------------------
94+
95+
#ifdef __cplusplus
96+
}
97+
#endif

0 commit comments

Comments
 (0)