Skip to content

Commit d6b9fef

Browse files
authored
Merge pull request #364 from RedisLabsModules/2.0.5
2 parents 79c8b36 + 138da2a commit d6b9fef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3595
-196
lines changed

.circleci/config.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ commands:
7171
parameters:
7272
redis_version:
7373
type: string
74-
default: "7.2-rc1"
74+
default: "7.2"
7575
getredis_params:
7676
type: string
7777
default: ""
@@ -101,7 +101,7 @@ commands:
101101
default: ""
102102
redis_version:
103103
type: string
104-
default: "7.2-rc1"
104+
default: "7.2"
105105
getredis_params:
106106
type: string
107107
default: ""
@@ -111,6 +111,11 @@ commands:
111111
- install-prerequisites:
112112
redis_version: <<parameters.redis_version>>
113113
getredis_params: <<parameters.getredis_params>>
114+
- run:
115+
name: patch macos tests # Avoid AVX with Regex with CircleCI since virtualization layer doesn't support it. Use sed to replace the relevant entry in cargo.toml
116+
command: |
117+
if [[ $(uname -s) == Darwin ]]; then sed -i 's/regex = "1"/regex = { version = "1", features = ["perf", "unicode"] }/g' Cargo.toml; fi
118+
cat Cargo.toml
114119
- restore_cache:
115120
keys:
116121
- v3-dependencies-{{ arch }}-{{ checksum "Cargo.toml" }}
@@ -203,7 +208,7 @@ jobs:
203208

204209
build-macos-x64:
205210
macos:
206-
xcode: 13.2.1
211+
xcode: 13.4.1
207212
resource_class: macos.x86.medium.gen2
208213
steps:
209214
- build-steps

.github/workflows/freebsd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ jobs:
2626
sh rustup.sh -y
2727
. $HOME/.cargo/env
2828
rustup target add i686-unknown-freebsd
29-
cargo build --all --all-targets --verbose --target i686-unknown-freebsd
29+
cargo build --all --all-targets --verbose --no-default-features --target i686-unknown-freebsd
3030

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Cargo
22
# will have compiled files and executables
3-
/target/
3+
**/target/
44

55
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
66
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
@@ -21,3 +21,5 @@ dump.rdb
2121

2222
# Debugger-related files:
2323
.gdb_history
24+
25+
venv/

Cargo.toml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis-module"
3-
version = "99.99.99"
3+
version = "2.0.5"
44
authors = ["Gavrie Philipson <[email protected]>", "Guy Korland <[email protected]>"]
55
edition = "2021"
66
build = "build.rs"
@@ -23,13 +23,18 @@ crate-type = ["cdylib"]
2323
name = "configuration"
2424
crate-type = ["cdylib"]
2525

26+
[[example]]
27+
name = "proc_macro_commands"
28+
crate-type = ["cdylib"]
29+
2630
[[example]]
2731
name = "acl"
2832
crate-type = ["cdylib"]
2933

3034
[[example]]
3135
name = "call"
3236
crate-type = ["cdylib"]
37+
required-features = ["min-redis-compatibility-version-7-2"]
3338

3439
[[example]]
3540
name = "keys_pos"
@@ -75,6 +80,22 @@ crate-type = ["cdylib"]
7580
name = "test_helper"
7681
crate-type = ["cdylib"]
7782

83+
[[example]]
84+
name = "info_handler_macro"
85+
crate-type = ["cdylib"]
86+
87+
[[example]]
88+
name = "info_handler_builder"
89+
crate-type = ["cdylib"]
90+
91+
[[example]]
92+
name = "info_handler_struct"
93+
crate-type = ["cdylib"]
94+
95+
[[example]]
96+
name = "info_handler_multiple_sections"
97+
crate-type = ["cdylib"]
98+
7899
[[example]]
79100
name = "info"
80101
crate-type = ["cdylib"]
@@ -91,8 +112,12 @@ crate-type = ["cdylib"]
91112
name = "response"
92113
crate-type = ["cdylib"]
93114

115+
[[example]]
116+
name = "open_key_with_flags"
117+
crate-type = ["cdylib"]
118+
94119
[dependencies]
95-
bitflags = "2.1"
120+
bitflags = "2"
96121
libc = "0.2"
97122
enum-primitive-derive = "^0.1"
98123
num-traits = "^0.2"
@@ -104,16 +129,17 @@ serde = { version = "1", features = ["derive"] }
104129
nix = "0.26"
105130
cfg-if = "1"
106131
redis-module-macros-internals = { path = "./redismodule-rs-macros-internals" }
132+
log = "0.4"
107133

108134
[dev-dependencies]
109135
anyhow = "1"
110136
redis = "0.23"
111137
lazy_static = "1"
112138
redis-module-macros = { path = "./redismodule-rs-macros"}
113-
redis-module = { path = "./" }
139+
redis-module = { path = "./", default-features = false, features = ["min-redis-compatibility-version-7-2"] }
114140

115141
[build-dependencies]
116-
bindgen = "0.65"
142+
bindgen = "0.66"
117143
cc = "1"
118144

119145
[features]

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ RUST_SOEXT.freebsd=so
5757
RUST_SOEXT.macos=dylib
5858

5959
build:
60-
cargo build --all --all-targets $(CARGO_FLAGS)
60+
cargo build --all --all-targets --no-default-features $(CARGO_FLAGS)
6161
# cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)
6262

6363
clean:
@@ -74,8 +74,8 @@ endif
7474
test: cargo_test
7575

7676
cargo_test:
77-
cargo test --workspace $(CARGO_FLAGS)
78-
cargo test --doc --workspace $(CARGO_FLAGS)
77+
cargo test --workspace --no-default-features $(CARGO_FLAGS)
78+
cargo test --doc --workspace --no-default-features $(CARGO_FLAGS)
7979

8080
.PHONY: test cargo_test
8181

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
2-
cargo build --features experimental-api,test --all --all-targets
2+
cargo build --all --all-targets --no-default-features
33

44

deps/readies

examples/call.rs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use redis_module::{
2-
redis_module, CallOptionResp, CallOptionsBuilder, CallReply, CallResult, Context, RedisError,
3-
RedisResult, RedisString,
2+
redis_module, BlockedClient, CallOptionResp, CallOptionsBuilder, CallReply, CallResult,
3+
Context, FutureCallReply, PromiseCallReply, RedisError, RedisResult, RedisString, RedisValue,
4+
ThreadSafeContext,
45
};
56

7+
use std::thread;
8+
69
fn call_test(ctx: &Context, _: Vec<RedisString>) -> RedisResult {
710
let res: String = ctx.call("ECHO", &["TEST"])?.try_into()?;
811
if "TEST" != &res {
@@ -110,6 +113,49 @@ fn call_test(ctx: &Context, _: Vec<RedisString>) -> RedisResult {
110113
Ok("pass".into())
111114
}
112115

116+
fn call_blocking_internal(ctx: &Context) -> PromiseCallReply {
117+
let call_options = CallOptionsBuilder::new().build_blocking();
118+
ctx.call_blocking("blpop", &call_options, &["list", "1"])
119+
}
120+
121+
fn call_blocking_handle_future(ctx: &Context, f: FutureCallReply, blocked_client: BlockedClient) {
122+
let future_handler = f.set_unblock_handler(move |_ctx, reply| {
123+
let thread_ctx = ThreadSafeContext::with_blocked_client(blocked_client);
124+
thread_ctx.reply(reply.map_or_else(|e| Err(e.into()), |v| Ok((&v).into())));
125+
});
126+
future_handler.dispose(ctx);
127+
}
128+
129+
fn call_blocking(ctx: &Context, _: Vec<RedisString>) -> RedisResult {
130+
let res = call_blocking_internal(ctx);
131+
match res {
132+
PromiseCallReply::Resolved(r) => r.map_or_else(|e| Err(e.into()), |v| Ok((&v).into())),
133+
PromiseCallReply::Future(f) => {
134+
let blocked_client = ctx.block_client();
135+
call_blocking_handle_future(ctx, f, blocked_client);
136+
Ok(RedisValue::NoReply)
137+
}
138+
}
139+
}
140+
141+
fn call_blocking_from_detach_ctx(ctx: &Context, _: Vec<RedisString>) -> RedisResult {
142+
let blocked_client = ctx.block_client();
143+
thread::spawn(move || {
144+
let ctx_guard = redis_module::MODULE_CONTEXT.lock();
145+
let res = call_blocking_internal(&ctx_guard);
146+
match res {
147+
PromiseCallReply::Resolved(r) => {
148+
let thread_ctx = ThreadSafeContext::with_blocked_client(blocked_client);
149+
thread_ctx.reply(r.map_or_else(|e| Err(e.into()), |v| Ok((&v).into())));
150+
}
151+
PromiseCallReply::Future(f) => {
152+
call_blocking_handle_future(&ctx_guard, f, blocked_client);
153+
}
154+
}
155+
});
156+
Ok(RedisValue::NoReply)
157+
}
158+
113159
//////////////////////////////////////////////////////
114160

115161
redis_module! {
@@ -119,5 +165,7 @@ redis_module! {
119165
data_types: [],
120166
commands: [
121167
["call.test", call_test, "", 0, 0, 0],
168+
["call.blocking", call_blocking, "", 0, 0, 0],
169+
["call.blocking_from_detached_ctx", call_blocking_from_detach_ctx, "", 0, 0, 0],
122170
],
123171
}

examples/data_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static MY_REDIS_TYPE: RedisType = RedisType::new(
2424
// Aux data
2525
aux_load: None,
2626
aux_save: None,
27+
aux_save2: None,
2728
aux_save_triggers: 0,
2829

2930
free_effort: None,

examples/events.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use redis_module::apierror::APIResult;
21
use redis_module::{
32
redis_module, Context, NotifyEvent, RedisError, RedisResult, RedisString, RedisValue, Status,
43
};
@@ -19,7 +18,7 @@ fn on_event(ctx: &Context, event_type: NotifyEvent, event: &str, key: &[u8]) {
1918
event
2019
);
2120
ctx.log_notice(msg.as_str());
22-
let _: APIResult<Status> = ctx.add_post_notification_job(|ctx| {
21+
let _ = ctx.add_post_notification_job(|ctx| {
2322
// it is not safe to write inside the notification callback itself.
2423
// So we perform the write on a post job notificaiton.
2524
if let Err(e) = ctx.call("incr", &["num_sets"]) {

0 commit comments

Comments
 (0)