Skip to content

Commit 5fa5800

Browse files
author
Dmitry Polyakovsky
committed
fixed tests
RedisKeyWritable, RedisLogLevel, RedisGlobalLogger, RedisLockIndicator, RedisGILGuardScope, RedisCommandFlags RedisCommandKeySpecFlags, RedisModuleCallback, RedisKey, REDIS_OK, MY_REDIS_TYPE start_redis_server_with_module, get_redis_connection updated numerous text references to Redis Signed-off-by: Dmitry Polyakovsky <[email protected]>
1 parent 03e99c4 commit 5fa5800

28 files changed

+343
-349
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ src/redisraw/bindings.rs
1212
# VS Code
1313
.vscode
1414

15-
# Redis database
15+
# Valkey database
1616
dump.rdb
1717

1818
# Debugger-related files:

build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::env;
66
use std::path::PathBuf;
77

88
#[derive(Debug)]
9-
struct RedisModuleCallback;
9+
struct ValkeyModuleCallback;
1010

11-
impl ParseCallbacks for RedisModuleCallback {
11+
impl ParseCallbacks for ValkeyModuleCallback {
1212
fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> {
1313
if name.starts_with("REDISMODULE_SUBEVENT_") || name.starts_with("REDISMODULE_EVENT_") {
1414
Some(IntKind::U64)
@@ -34,10 +34,10 @@ impl ParseCallbacks for RedisModuleCallback {
3434
}
3535

3636
fn main() {
37-
// Build a Redis pseudo-library so that we have symbols that we can link
37+
// Build a Valkey pseudo-library so that we have symbols that we can link
3838
// against while building Rust code.
3939
//
40-
// include/redismodule.h is vendored in from the Redis project and
40+
// include/redismodule.h is vendored in from the Valkey project and
4141
// src/redismodule.c is a stub that includes it and plays a few other
4242
// tricks that we need to complete the build.
4343

@@ -59,7 +59,7 @@ fn main() {
5959
.allowlist_var("(REDIS|Redis).*")
6060
.blocklist_type("__darwin_.*")
6161
.allowlist_type("RedisModule.*")
62-
.parse_callbacks(Box::new(RedisModuleCallback))
62+
.parse_callbacks(Box::new(ValkeyModuleCallback))
6363
.size_t_is_usize(true)
6464
.generate()
6565
.expect("error generating bindings");

examples/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn call_test(ctx: &Context, _: Vec<ValkeyString>) -> ValkeyResult {
5252
.try_into()?;
5353
if "TEST" != &res {
5454
return Err(ValkeyError::Str(
55-
"Failed calling 'ECHO TEST' with RedisString",
55+
"Failed calling 'ECHO TEST' with ValkeyString",
5656
));
5757
}
5858

@@ -61,7 +61,7 @@ fn call_test(ctx: &Context, _: Vec<ValkeyString>) -> ValkeyResult {
6161
.try_into()?;
6262
if "TEST" != &res {
6363
return Err(ValkeyError::Str(
64-
"Failed calling 'ECHO TEST' with dynamic array of RedisString",
64+
"Failed calling 'ECHO TEST' with dynamic array of ValkeyString",
6565
));
6666
}
6767

examples/data_type.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct MyType {
77
data: String,
88
}
99

10-
static MY_REDIS_TYPE: ValkeyType = ValkeyType::new(
10+
static MY_VALKEY_TYPE: ValkeyType = ValkeyType::new(
1111
"mytype123",
1212
0,
1313
raw::RedisModuleTypeMethods {
@@ -52,14 +52,14 @@ fn alloc_set(ctx: &Context, args: Vec<ValkeyString>) -> ValkeyResult {
5252

5353
let key = ctx.open_key_writable(&key);
5454

55-
if let Some(value) = key.get_value::<MyType>(&MY_REDIS_TYPE)? {
55+
if let Some(value) = key.get_value::<MyType>(&MY_VALKEY_TYPE)? {
5656
value.data = "B".repeat(size as usize);
5757
} else {
5858
let value = MyType {
5959
data: "A".repeat(size as usize),
6060
};
6161

62-
key.set_value(&MY_REDIS_TYPE, value)?;
62+
key.set_value(&MY_VALKEY_TYPE, value)?;
6363
}
6464
Ok(size.into())
6565
}
@@ -70,7 +70,7 @@ fn alloc_get(ctx: &Context, args: Vec<ValkeyString>) -> ValkeyResult {
7070

7171
let key = ctx.open_key(&key);
7272

73-
let value = match key.get_value::<MyType>(&MY_REDIS_TYPE)? {
73+
let value = match key.get_value::<MyType>(&MY_VALKEY_TYPE)? {
7474
Some(value) => value.data.as_str().into(),
7575
None => ().into(),
7676
};
@@ -85,7 +85,7 @@ valkey_module! {
8585
version: 1,
8686
allocator: (valkey_module::alloc::ValkeyAlloc, valkey_module::alloc::ValkeyAlloc),
8787
data_types: [
88-
MY_REDIS_TYPE,
88+
MY_VALKEY_TYPE,
8989
],
9090
commands: [
9191
["alloc.set", alloc_set, "write", 1, 1, 1],

examples/load_unload.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use valkey_module::{logging::RedisLogLevel, valkey_module, Context, Status, ValkeyString};
1+
use valkey_module::{logging::ValkeyLogLevel, valkey_module, Context, Status, ValkeyString};
22

33
static mut GLOBAL_STATE: Option<String> = None;
44

@@ -10,7 +10,7 @@ fn init(ctx: &Context, args: &[ValkeyString]) -> Status {
1010
(before, after)
1111
};
1212
ctx.log(
13-
RedisLogLevel::Warning,
13+
ValkeyLogLevel::Warning,
1414
&format!("Update global state on LOAD. BEFORE: {before:?}, AFTER: {after:?}",),
1515
);
1616

@@ -24,7 +24,7 @@ fn deinit(ctx: &Context) -> Status {
2424
(before, after)
2525
};
2626
ctx.log(
27-
RedisLogLevel::Warning,
27+
ValkeyLogLevel::Warning,
2828
&format!("Update global state on UNLOAD. BEFORE: {before:?}, AFTER: {after:?}"),
2929
);
3030

examples/scan_keys.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use valkey_module::{
2-
key::RedisKey, valkey_module, Context, KeysCursor, ValkeyResult, ValkeyString, ValkeyValue,
2+
key::ValkeyKey, valkey_module, Context, KeysCursor, ValkeyResult, ValkeyString, ValkeyValue,
33
};
44

55
fn scan_keys(ctx: &Context, _args: Vec<ValkeyString>) -> ValkeyResult {
66
let cursor = KeysCursor::new();
77
let mut res = Vec::new();
88

9-
let scan_callback = |_ctx: &Context, key_name: ValkeyString, _key: Option<&RedisKey>| {
9+
let scan_callback = |_ctx: &Context, key_name: ValkeyString, _key: Option<&ValkeyKey>| {
1010
res.push(ValkeyValue::BulkValkeyString(key_name));
1111
};
1212

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Parse for Args {
3131
}
3232

3333
/// This proc macro allows specifying which RedisModuleAPI is required by some redismodue-rs
34-
/// function. The macro finds, for a given set of RedisModuleAPI, what the minimal Redis version is
34+
/// function. The macro finds, for a given set of RedisModuleAPI, what the minimal Valkey version is
3535
/// that contains all those APIs and decides whether or not the function might raise an [APIError].
3636
///
3737
/// In addition, for each RedisModuleAPI, the proc macro injects a code that extracts the actual

redismodule-rs-macros/src/command.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use syn::{
1010
};
1111

1212
#[derive(Debug, Deserialize)]
13-
pub enum RedisCommandFlags {
13+
pub enum ValkeyCommandFlags {
1414
/// The command may modify the data set (it may also read from it).
1515
Write,
1616

@@ -82,29 +82,29 @@ pub enum RedisCommandFlags {
8282
GetchannelsApi,
8383
}
8484

85-
impl From<&RedisCommandFlags> for &'static str {
86-
fn from(value: &RedisCommandFlags) -> Self {
85+
impl From<&ValkeyCommandFlags> for &'static str {
86+
fn from(value: &ValkeyCommandFlags) -> Self {
8787
match value {
88-
RedisCommandFlags::Write => "write",
89-
RedisCommandFlags::ReadOnly => "readonly",
90-
RedisCommandFlags::Admin => "admin",
91-
RedisCommandFlags::DenyOOM => "deny-oom",
92-
RedisCommandFlags::DenyScript => "deny-script",
93-
RedisCommandFlags::AllowLoading => "allow-loading",
94-
RedisCommandFlags::PubSub => "pubsub",
95-
RedisCommandFlags::Random => "random",
96-
RedisCommandFlags::AllowStale => "allow-stale",
97-
RedisCommandFlags::NoMonitor => "no-monitor",
98-
RedisCommandFlags::NoSlowlog => "no-slowlog",
99-
RedisCommandFlags::Fast => "fast",
100-
RedisCommandFlags::GetkeysApi => "getkeys-api",
101-
RedisCommandFlags::NoCluster => "no-cluster",
102-
RedisCommandFlags::NoAuth => "no-auth",
103-
RedisCommandFlags::MayReplicate => "may-replicate",
104-
RedisCommandFlags::NoMandatoryKeys => "no-mandatory-keys",
105-
RedisCommandFlags::Blocking => "blocking",
106-
RedisCommandFlags::AllowBusy => "allow-busy",
107-
RedisCommandFlags::GetchannelsApi => "getchannels-api",
88+
ValkeyCommandFlags::Write => "write",
89+
ValkeyCommandFlags::ReadOnly => "readonly",
90+
ValkeyCommandFlags::Admin => "admin",
91+
ValkeyCommandFlags::DenyOOM => "deny-oom",
92+
ValkeyCommandFlags::DenyScript => "deny-script",
93+
ValkeyCommandFlags::AllowLoading => "allow-loading",
94+
ValkeyCommandFlags::PubSub => "pubsub",
95+
ValkeyCommandFlags::Random => "random",
96+
ValkeyCommandFlags::AllowStale => "allow-stale",
97+
ValkeyCommandFlags::NoMonitor => "no-monitor",
98+
ValkeyCommandFlags::NoSlowlog => "no-slowlog",
99+
ValkeyCommandFlags::Fast => "fast",
100+
ValkeyCommandFlags::GetkeysApi => "getkeys-api",
101+
ValkeyCommandFlags::NoCluster => "no-cluster",
102+
ValkeyCommandFlags::NoAuth => "no-auth",
103+
ValkeyCommandFlags::MayReplicate => "may-replicate",
104+
ValkeyCommandFlags::NoMandatoryKeys => "no-mandatory-keys",
105+
ValkeyCommandFlags::Blocking => "blocking",
106+
ValkeyCommandFlags::AllowBusy => "allow-busy",
107+
ValkeyCommandFlags::GetchannelsApi => "getchannels-api",
108108
}
109109
}
110110
}
@@ -125,7 +125,7 @@ impl From<&RedisEnterpriseCommandFlags> for &'static str {
125125
}
126126

127127
#[derive(Debug, Deserialize)]
128-
pub enum RedisCommandKeySpecFlags {
128+
pub enum ValkeyCommandKeySpecFlags {
129129
/// Read-Only. Reads the value of the key, but doesn't necessarily return it.
130130
ReadOnly,
131131

@@ -160,20 +160,20 @@ pub enum RedisCommandKeySpecFlags {
160160
VariableFlags,
161161
}
162162

163-
impl From<&RedisCommandKeySpecFlags> for &'static str {
164-
fn from(value: &RedisCommandKeySpecFlags) -> Self {
163+
impl From<&ValkeyCommandKeySpecFlags> for &'static str {
164+
fn from(value: &ValkeyCommandKeySpecFlags) -> Self {
165165
match value {
166-
RedisCommandKeySpecFlags::ReadOnly => "READ_ONLY",
167-
RedisCommandKeySpecFlags::ReadWrite => "READ_WRITE",
168-
RedisCommandKeySpecFlags::Overwrite => "OVERWRITE",
169-
RedisCommandKeySpecFlags::Remove => "REMOVE",
170-
RedisCommandKeySpecFlags::Access => "ACCESS",
171-
RedisCommandKeySpecFlags::Update => "UPDATE",
172-
RedisCommandKeySpecFlags::Insert => "INSERT",
173-
RedisCommandKeySpecFlags::Delete => "DELETE",
174-
RedisCommandKeySpecFlags::NotKey => "NOT_KEY",
175-
RedisCommandKeySpecFlags::Incomplete => "INCOMPLETE",
176-
RedisCommandKeySpecFlags::VariableFlags => "VARIABLE_FLAGS",
166+
ValkeyCommandKeySpecFlags::ReadOnly => "READ_ONLY",
167+
ValkeyCommandKeySpecFlags::ReadWrite => "READ_WRITE",
168+
ValkeyCommandKeySpecFlags::Overwrite => "OVERWRITE",
169+
ValkeyCommandKeySpecFlags::Remove => "REMOVE",
170+
ValkeyCommandKeySpecFlags::Access => "ACCESS",
171+
ValkeyCommandKeySpecFlags::Update => "UPDATE",
172+
ValkeyCommandKeySpecFlags::Insert => "INSERT",
173+
ValkeyCommandKeySpecFlags::Delete => "DELETE",
174+
ValkeyCommandKeySpecFlags::NotKey => "NOT_KEY",
175+
ValkeyCommandKeySpecFlags::Incomplete => "INCOMPLETE",
176+
ValkeyCommandKeySpecFlags::VariableFlags => "VARIABLE_FLAGS",
177177
}
178178
}
179179
}
@@ -218,15 +218,15 @@ pub enum BeginSearch {
218218
#[derive(Debug, Deserialize)]
219219
pub struct KeySpecArg {
220220
notes: Option<String>,
221-
flags: Vec<RedisCommandKeySpecFlags>,
221+
flags: Vec<ValkeyCommandKeySpecFlags>,
222222
begin_search: BeginSearch,
223223
find_keys: FindKeys,
224224
}
225225

226226
#[derive(Debug, Deserialize)]
227227
struct Args {
228228
name: Option<String>,
229-
flags: Vec<RedisCommandFlags>,
229+
flags: Vec<ValkeyCommandFlags>,
230230
enterprise_flags: Option<Vec<RedisEnterpriseCommandFlags>>,
231231
summary: Option<String>,
232232
complexity: Option<String>,

redismodule-rs-macros/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod command;
66
mod info_section;
77
mod redis_value;
88

9-
/// This proc macro allow to specify that the follow function is a Redis command.
9+
/// This proc macro allow to specify that the follow function is a Valkey command.
1010
/// The macro accept the following arguments that discribe the command properties:
1111
/// * name (optional) - The command name. in case not given, the function name will be taken.
1212
/// * flags - An array of [`command::RedisCommandFlags`].
@@ -31,12 +31,12 @@ mod redis_value;
3131
/// * NotKey - The key is not actually a key, but should be routed in cluster mode as if it was a key.
3232
/// * Incomplete - The keyspec might not point out all the keys it should cover.
3333
/// * VariableFlags - Some keys might have different flags depending on arguments.
34-
/// * begin_search - Represents how Redis should start looking for keys.
34+
/// * begin_search - Represents how Valkey should start looking for keys.
3535
/// There are 2 possible options:
3636
/// * Index - start looking for keys from a given position.
3737
/// * Keyword - Search for a specific keyward and start looking for keys from this keyword
38-
/// * FindKeys - After Redis finds the location from where it needs to start looking for keys,
39-
/// Redis will start finding keys base on the information in this struct.
38+
/// * FindKeys - After Valkey finds the location from where it needs to start looking for keys,
39+
/// Valkey will start finding keys base on the information in this struct.
4040
/// There are 2 possible options:
4141
/// * Range - An object of three element `last_key`, `steps`, `limit`.
4242
/// * last_key - Index of the last key relative to the result of the
@@ -80,7 +80,7 @@ mod redis_value;
8080
/// }
8181
/// ```
8282
///
83-
/// **Notice**, by default Redis does not validate the command spec. User should validate the command keys on the module command code. The command spec is used for validation on cluster so Redis can raise a cross slot error when needed.
83+
/// **Notice**, by default Valkey does not validate the command spec. User should validate the command keys on the module command code. The command spec is used for validation on cluster so Valkey can raise a cross slot error when needed.
8484
#[proc_macro_attribute]
8585
pub fn command(attr: TokenStream, item: TokenStream) -> TokenStream {
8686
command::redis_command(attr, item)
@@ -197,7 +197,7 @@ pub fn config_changed_event_handler(_attr: TokenStream, item: TokenStream) -> To
197197
gen.into()
198198
}
199199

200-
/// Proc macro which is set on a function that need to be called on Redis cron.
200+
/// Proc macro which is set on a function that need to be called on Valkey cron.
201201
/// The function must accept a [Context] and [u64] that represent the cron hz.
202202
///
203203
/// Example:

src/alloc.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ fn allocation_free_panic(message: &'static str) -> ! {
1616
std::process::abort();
1717
}
1818

19-
const REDIS_ALLOCATOR_NOT_AVAILABLE_MESSAGE: &str =
20-
"Critical error: the Redis Allocator isn't available.\n";
19+
const VALKEY_ALLOCATOR_NOT_AVAILABLE_MESSAGE: &str =
20+
"Critical error: the Valkey Allocator isn't available.\n";
2121

22-
/// Defines the Redis allocator. This allocator delegates the allocation
23-
/// and deallocation tasks to the Redis server when available, otherwise
22+
/// Defines the Valkey allocator. This allocator delegates the allocation
23+
/// and deallocation tasks to the Valkey server when available, otherwise
2424
/// it panics.
2525
#[derive(Copy, Clone)]
2626
pub struct ValkeyAlloc;
2727

2828
unsafe impl GlobalAlloc for ValkeyAlloc {
2929
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
3030
/*
31-
* To make sure the memory allocation by Redis is aligned to the according to the layout,
31+
* To make sure the memory allocation by Valkey is aligned to the according to the layout,
3232
* we need to align the size of the allocation to the layout.
3333
*
3434
* "Memory is conceptually broken into equal-sized chunks,
@@ -42,14 +42,14 @@ unsafe impl GlobalAlloc for ValkeyAlloc {
4242

4343
match raw::RedisModule_Alloc {
4444
Some(alloc) => alloc(size).cast(),
45-
None => allocation_free_panic(REDIS_ALLOCATOR_NOT_AVAILABLE_MESSAGE),
45+
None => allocation_free_panic(VALKEY_ALLOCATOR_NOT_AVAILABLE_MESSAGE),
4646
}
4747
}
4848

4949
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
5050
match raw::RedisModule_Free {
5151
Some(f) => f(ptr.cast()),
52-
None => allocation_free_panic(REDIS_ALLOCATOR_NOT_AVAILABLE_MESSAGE),
52+
None => allocation_free_panic(VALKEY_ALLOCATOR_NOT_AVAILABLE_MESSAGE),
5353
};
5454
}
5555
}

0 commit comments

Comments
 (0)