Skip to content

Commit

Permalink
add RM_AddACLCategory (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephraimfeldblum authored Oct 31, 2024
1 parent f9c8dca commit 34d9ec8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ cc = "1"

[features]
default = ["min-redis-compatibility-version-6-0"]
min-redis-compatibility-version-7-4 = ["redis-module/min-redis-compatibility-version-7-4"]
min-redis-compatibility-version-7-2 = ["redis-module/min-redis-compatibility-version-7-2"]
min-redis-compatibility-version-7-0 = ["redis-module/min-redis-compatibility-version-7-0"]
min-redis-compatibility-version-6-2 = ["redis-module/min-redis-compatibility-version-6-2"]
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
cargo build --all --all-targets --no-default-features
cargo build --all --all-targets --no-default-features --features min-redis-compatibility-version-7-4


2 changes: 2 additions & 0 deletions redismodule-rs-macros-internals/src/api_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use quote::quote;

lazy_static::lazy_static! {
pub(crate) static ref API_VERSION_MAPPING: HashMap<String, usize> = HashMap::from([
("RedisModule_AddACLCategory".to_string(), 70400),
("RedisModule_AddPostNotificationJob".to_string(), 70200),
("RedisModule_SetCommandACLCategories".to_string(), 70200),
("RedisModule_GetOpenKeyModesAll".to_string(), 70200),
Expand All @@ -30,6 +31,7 @@ lazy_static::lazy_static! {
(60200, "min-redis-compatibility-version-6-2".to_string()),
(70000, "min-redis-compatibility-version-7-0".to_string()),
(70200, "min-redis-compatibility-version-7-2".to_string()),
(70400, "min-redis-compatibility-version-7-4".to_string()),
];
}

Expand Down
2 changes: 2 additions & 0 deletions src/context/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ api! {[

#[cfg(all(
any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2",
feature = "min-redis-compatibility-version-7-0"
),
Expand All @@ -495,6 +496,7 @@ pub fn register_commands(ctx: &Context) -> Status {
feature = "min-redis-compatibility-version-6-0"
),
not(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2",
feature = "min-redis-compatibility-version-7-0"
))
Expand Down
15 changes: 12 additions & 3 deletions src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ pub struct CallOptions {
}

#[derive(Clone)]
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
pub struct BlockingCallOptions {
options: CString,
}
Expand Down Expand Up @@ -136,7 +139,10 @@ impl CallOptionsBuilder {
/// Construct a CallOption object that can be used to run commands using call_blocking.
/// The commands can be either blocking or none blocking. In case the command are blocking
/// (like `blpop`) a [FutureCallReply] will be returned.
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
pub fn build_blocking(mut self) -> BlockingCallOptions {
self.add_flag("K");
BlockingCallOptions {
Expand Down Expand Up @@ -441,7 +447,10 @@ impl Context {
}

/// Same as [call_ext] but also allow to perform blocking commands like BLPOP.
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
pub fn call_blocking<
'ctx,
'a,
Expand Down
1 change: 1 addition & 0 deletions src/include/redismodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ REDISMODULE_API RedisModuleCommand *(*RedisModule_GetCommand)(RedisModuleCtx *ct
REDISMODULE_API int (*RedisModule_CreateSubcommand)(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_SetCommandInfo)(RedisModuleCommand *command, const RedisModuleCommandInfo *info) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_SetCommandACLCategories)(RedisModuleCommand *command, const char *ctgrsflags) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_AddACLCategory)(RedisModuleCtx *ctx, const char *name) REDISMODULE_ATTR;
REDISMODULE_API void (*RedisModule_SetModuleAttribs)(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_IsModuleNameBusy)(const char *name) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_WrongArity)(RedisModuleCtx *ctx) REDISMODULE_ATTR;
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ pub use crate::context::defrag;
pub use crate::context::keys_cursor::KeysCursor;
pub use crate::context::server_events;
pub use crate::context::AclPermissions;
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
pub use crate::context::BlockingCallOptions;
pub use crate::context::CallOptionResp;
pub use crate::context::CallOptions;
Expand Down
10 changes: 8 additions & 2 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ fn test_stream_reader() -> Result<()> {
}

#[test]
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
fn test_call() -> Result<()> {
let port: u16 = 6488;
let _guards = vec![start_redis_server_with_module("call", port)
Expand Down Expand Up @@ -631,7 +634,10 @@ fn test_redis_value_derive() -> Result<()> {
}

#[test]
#[cfg(feature = "min-redis-compatibility-version-7-2")]
#[cfg(any(
feature = "min-redis-compatibility-version-7-4",
feature = "min-redis-compatibility-version-7-2"
))]
fn test_call_blocking() -> Result<()> {
let port: u16 = 6499;
let _guards = vec![start_redis_server_with_module("call", port)
Expand Down

0 comments on commit 34d9ec8

Please sign in to comment.