Skip to content

Commit 503d94e

Browse files
author
Meir Shpilraien (Spielrein)
authored
Merge pull request #406 from RedisLabsModules/merge_master_to_2.1
Merge master to 2.1
2 parents 2aa3463 + d233173 commit 503d94e

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- [7-0, "7.2"]
1919
- [7-2, "7.2"]
2020
toolchain:
21-
- 1.78.0
21+
- 1.81.0
2222
- stable
2323

2424
steps:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis-module"
3-
version = "2.1.0"
3+
version = "2.1.1"
44
authors = ["Gavrie Philipson <gavrie@redis.com>", "Guy Korland <guy.korland@redis.com>"]
55
edition = "2021"
66
build = "build.rs"

src/context/commands.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ pub fn register_commands(ctx: &Context) -> Status {
504504
pub fn register_commands(ctx: &Context) -> Status {
505505
register_commands_internal(ctx).map_or_else(
506506
|e| {
507+
/* Make sure new command registration API is not been used. */
508+
if COMMANDS_LIST.is_empty() {
509+
return Status::Ok;
510+
}
507511
ctx.log_warning(&e.to_string());
508512
Status::Err
509513
},

src/macros.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ macro_rules! redis_command {
1010
$mandatory_acl_categories:expr
1111
$(, $optional_acl_categories:expr)?
1212
) => {{
13-
use redis_module::AclCategory;
13+
use $crate::AclCategory;
1414

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

51-
let command =
52-
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
53-
if command.is_null() {
54-
$crate::raw::redis_log(
55-
$ctx,
56-
&format!("Error: failed to get command {}", $command_name),
57-
);
58-
return $crate::raw::Status::Err as c_int;
59-
}
60-
6151
let mandatory = AclCategory::from($mandatory_acl_categories);
6252
if let Some(RM_SetCommandACLCategories) = $crate::raw::RedisModule_SetCommandACLCategories {
53+
let command =
54+
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
55+
if command.is_null() {
56+
$crate::raw::redis_log(
57+
$ctx,
58+
&format!("Error: failed to get command {}", $command_name),
59+
);
60+
return $crate::raw::Status::Err as c_int;
61+
}
6362
let mut optional_failed = true;
6463
let mut acl_categories = CString::default();
6564
$(
@@ -417,7 +416,9 @@ macro_rules! redis_module {
417416
register_enum_configuration(&context, $enum_configuration_name, $enum_configuration_val, default, $enum_flags_options, $enum_on_changed);
418417
)*
419418
)?
420-
raw::RedisModule_LoadConfigs.unwrap()(ctx);
419+
if let Some(load_config) = raw::RedisModule_LoadConfigs {
420+
load_config(ctx);
421+
}
421422

422423
$(
423424
$crate::redis_command!(ctx, $module_config_get_command, |ctx, args: Vec<RedisString>| {

0 commit comments

Comments
 (0)