Skip to content

Merge master to 2.1 #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- [7-0, "7.2"]
- [7-2, "7.2"]
toolchain:
- 1.78.0
- 1.81.0
- stable

steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redis-module"
version = "2.1.0"
version = "2.1.1"
authors = ["Gavrie Philipson <gavrie@redis.com>", "Guy Korland <guy.korland@redis.com>"]
edition = "2021"
build = "build.rs"
Expand Down
4 changes: 4 additions & 0 deletions src/context/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ pub fn register_commands(ctx: &Context) -> Status {
pub fn register_commands(ctx: &Context) -> Status {
register_commands_internal(ctx).map_or_else(
|e| {
/* Make sure new command registration API is not been used. */
if COMMANDS_LIST.is_empty() {
return Status::Ok;
}
ctx.log_warning(&e.to_string());
Status::Err
},
Expand Down
25 changes: 13 additions & 12 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! redis_command {
$mandatory_acl_categories:expr
$(, $optional_acl_categories:expr)?
) => {{
use redis_module::AclCategory;
use $crate::AclCategory;

let name = CString::new($command_name).unwrap();
let flags = CString::new($command_flags).unwrap();
Expand Down Expand Up @@ -48,18 +48,17 @@ macro_rules! redis_command {
return $crate::raw::Status::Err as c_int;
}

let command =
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
if command.is_null() {
$crate::raw::redis_log(
$ctx,
&format!("Error: failed to get command {}", $command_name),
);
return $crate::raw::Status::Err as c_int;
}

let mandatory = AclCategory::from($mandatory_acl_categories);
if let Some(RM_SetCommandACLCategories) = $crate::raw::RedisModule_SetCommandACLCategories {
let command =
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
if command.is_null() {
$crate::raw::redis_log(
$ctx,
&format!("Error: failed to get command {}", $command_name),
);
return $crate::raw::Status::Err as c_int;
}
let mut optional_failed = true;
let mut acl_categories = CString::default();
$(
Expand Down Expand Up @@ -417,7 +416,9 @@ macro_rules! redis_module {
register_enum_configuration(&context, $enum_configuration_name, $enum_configuration_val, default, $enum_flags_options, $enum_on_changed);
)*
)?
raw::RedisModule_LoadConfigs.unwrap()(ctx);
if let Some(load_config) = raw::RedisModule_LoadConfigs {
load_config(ctx);
}

$(
$crate::redis_command!(ctx, $module_config_get_command, |ctx, args: Vec<RedisString>| {
Expand Down
Loading