-
Notifications
You must be signed in to change notification settings - Fork 66
Comparing changes
Open a pull request
base repository: RedisLabsModules/redismodule-rs
base: v2.0.1
head repository: RedisLabsModules/redismodule-rs
compare: refs/heads/master
Commits on May 4, 2023
-
toml-editor can only set strings value. This is good enough for us because we do not really need the path argument.
Configuration menu - View commit details
-
Copy full SHA for 32c2925 - Browse repository at this point
Copy the full SHA 32c2925View commit details -
Added extra-traits feature to syn dependency so we will get the Debug trait implementation.
Configuration menu - View commit details
-
Copy full SHA for 02c1ab3 - Browse repository at this point
Copy the full SHA 02c1ab3View commit details -
Provide the standard logging facility implementation.
As the crate is mostly used as a redis module, the logging will most likely be only useful when printed on the server. As many rustaceans are familiar and used to using the de-facto standard "log" crate, it makes sense to provide the logging implementation for this crate to enable the most-commonly used way of logging messages in Rust.
Configuration menu - View commit details
-
Copy full SHA for 409e17e - Browse repository at this point
Copy the full SHA 409e17eView commit details
Commits on May 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for de65b4e - Browse repository at this point
Copy the full SHA de65b4eView commit details -
Merge pull request #318 from RedisLabsModules/add-logging-implementation
Provide the standard logging facility implementation.
Configuration menu - View commit details
-
Copy full SHA for 2cba2be - Browse repository at this point
Copy the full SHA 2cba2beView commit details -
Use
BTreeMap
andBTreeSet
in addition toHashMap
andHashSet
. (……#327) The main problem with HashMap and HashSet is that those are unordered. So we get results in different order each time. Using BTreeMap and BTreeSet we will get the results in the same order each time.
Configuration menu - View commit details
-
Copy full SHA for 82c4753 - Browse repository at this point
Copy the full SHA 82c4753View commit details
Commits on May 15, 2023
-
Changed post notification job to recieve FnOnce. (#329)
Redis promise that the callback will be called exactly once so we can use FnOnce instead of Fn and have a better flexibility on the callback implementation (for example, the callback will be able to pass ownership of captured variables).
Configuration menu - View commit details
-
Copy full SHA for 3ce2351 - Browse repository at this point
Copy the full SHA 3ce2351View commit details -
The PR introduce a new proc macro for command registrations. (#326)
The PR introduce a new proc macro for command registrations with the new command registration API that was introduced on Redis 7. The new proc macro are called `command`, The following command will register the `test_command` function as a Redis command called `foo`: ```rust #[command( { name: "test", flags: [ReadOnly], arity: -2, key_spec: [ { notes: "test command that define all the arguments at even possition as keys", flags: [ReadOnly, Access], begin_search: Keyword({ keyword : "foo", startfrom : 1 }), find_keys: Range({ last_key :- 1, steps : 2, limit : 0 }), } ] } )] fn test_command(_ctx: &Context, _args: Vec<RedisString>) -> RedisResult { Ok(RedisValue::SimpleStringStatic("OK")) } ``` The supported properties are: * name - The command name, * flags - An array of `RedisCommandFlags`. * summary (optional) - Command summary * complexity (optional) - Command compexity * since (optional) - At which module version the command was first introduce * tips (optional) - Command tips for proxy, for more information please refer to https://redis.io/topics/command-tips * arity - Number of arguments, including the command name itself. A positive number specifies an exact number of arguments and a negative number specifies a minimum number of arguments. * key_spec - A list of specs representing how to find the keys that the command might touch. the following options are available: * notes (optional) - Some note about the key spec. * flags - List of flags reprenting how the keys are accessed, the following options are available: * Readonly - Read-Only. Reads the value of the key, but doesn't necessarily return it. * ReadWrite - Read-Write. Modifies the data stored in the value of the key or its metadata. * Overwrite - Overwrite. Overwrites the data stored in the value of the key. * Remove - Deletes the key. * Access - Returns, copies or uses the user data from the value of the key. * Update - Updates data to the value, new value may depend on the old value. * Insert - Adds data to the value with no chance of modification or deletion of existing data. * Delete - Explicitly deletes some content from the value of the key. * NotKey - The key is not actually a key, but should be routed in cluster mode as if it was a key. * Incomplete - The keyspec might not point out all the keys it should cover. * VariableFlags - Some keys might have different flags depending on arguments. * begin_search - Represents how Redis should start looking for keys.There are 2 possible options: * Index - start looking for keys from a given position. * Keyword - Search for a specific keyward and start looking for keys from this keyword * FindKeys - After Redis finds the location from where it needs to start looking for keys, Redis will start finding keys base on the information in this struct. There are 2 possible options: * Range - An object of three elements `last_key`, `steps`, `limit`. * last_key - Index of the last key relative to the result of the begin search step. Can be negative, in which case it's not relative. -1 indicates the last argument, -2 one before the last and so on. * steps - How many arguments should we skip after finding a key, in order to find the next one. * limit - If `lastkey` is -1, we use `limit` to stop the search by a factor. 0 and 1 mean no limit. 2 means 1/2 of the remaining args, 3 means 1/3, and so on. * Keynum - An object of 3 elements `keynumidx`, `firstkey`, `keystep`. * keynumidx - Index of the argument containing the number of keys to come, relative to the result of the begin search step. * firstkey - Index of the fist key relative to the result of thebegin search step. (Usually it's just after `keynumidx`, inwhich case it should be set to `keynumidx + 1`.) * keystep - How many arguments should we skip after finding a key, in order to find the next one? **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. Ideas for future extensions: * The proc macro can analyze the function inputs and generate a code for parsing the command arguments so that the command function will not have to deal with it.
Configuration menu - View commit details
-
Copy full SHA for 0c708c5 - Browse repository at this point
Copy the full SHA 0c708c5View commit details
Commits on May 21, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 4306b65 - Browse repository at this point
Copy the full SHA 4306b65View commit details
Commits on May 22, 2023
-
Implements
RedisValue
derive proc macro. (#335)`RedisValue` derive proc macro allows to automatically generate the `From` trait of a given struct and convert it to `RedisValue`. Example: ```rust #[derive(RedisValue)] struct RedisValueDeriveInner { i: i64, } #[derive(RedisValue)] struct RedisValueDerive { i: i64, f: f64, s: String, u: usize, v: Vec<i64>, v2: Vec<RedisValueDeriveInner>, hash_map: HashMap<String, String>, hash_set: HashSet<String>, ordered_map: BTreeMap<String, RedisValueDeriveInner>, ordered_set: BTreeSet<String>, } #[command( { flags: [ReadOnly, NoMandatoryKeys], arity: -1, key_spec: [ { notes: "test redis value derive macro", flags: [ReadOnly, Access], begin_search: Index({ index : 0 }), find_keys: Range({ last_key : 0, steps : 0, limit : 0 }), } ] } )] fn redis_value_derive(_ctx: &Context, _args: Vec<RedisString>) -> RedisResult { Ok(RedisValueDerive { i: 10, f: 1.1, s: "s".to_owned(), u: 20, v: vec![1, 2, 3], v2: vec![ RedisValueDeriveInner { i: 1 }, RedisValueDeriveInner { i: 2 }, ], hash_map: HashMap::from([("key".to_owned(), "val`".to_owned())]), hash_set: HashSet::from(["key".to_owned()]), ordered_map: BTreeMap::from([("key".to_owned(), RedisValueDeriveInner { i: 10 })]), ordered_set: BTreeSet::from(["key".to_owned()]), } .into()) } ``` The `From` implementation generates a `RedisValue::OrderMap` such that the fields names are the map keys and the values are the result of running `Into` function on the field value and convert it into a `RedisValue`. The code above will generate the following reply (in resp3): ``` 127.0.0.1:6379> redis_value_derive 1# "f" => (double) 1.1 2# "hash_map" => 1# "key" => "val" 3# "hash_set" => 1~ "key" 4# "i" => (integer) 10 5# "ordered_map" => 1# "key" => 1# "i" => (integer) 10 6# "ordered_set" => 1~ "key" 7# "s" => "s" 8# "u" => (integer) 20 9# "v" => 1) (integer) 1 2) (integer) 2 3) (integer) 3 10# "v2" => 1) 1# "i" => (integer) 1 2) 1# "i" => (integer) 2 ```
Configuration menu - View commit details
-
Copy full SHA for b0939e7 - Browse repository at this point
Copy the full SHA b0939e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 576e20d - Browse repository at this point
Copy the full SHA 576e20dView commit details
Commits on May 23, 2023
-
Extend
RedisValue
derive macro. (#338)The PR extend the `RedisValue` derive macro with 2 new capabilities: 1. It is possible to use it on an Enum. In this case, the generated code will check the enum varient (using a match statement) and perform `Into` on the matched varient. This is usefull in case the command returns more than a single reply type and the reply type need to be decided at runtime. 2. It is possible to specify field attribute. that will define a specific behavior about the field. Supported attributes: * flatten - indicate to inlines keys from a field into the parent struct. Example: ```rust #[derive(RedisValue)] struct RedisValueDeriveInner { i2: i64, } #[derive(RedisValue)] struct RedisValueDerive { i1: i64, #[RedisValueAttr{flatten: true}] inner: RedisValueDeriveInner } ```
Configuration menu - View commit details
-
Copy full SHA for e1bffe3 - Browse repository at this point
Copy the full SHA e1bffe3View commit details -
Corrects the mapping of logging levels between Rust and Redis.
The Redis' verbose level is Rust's debug level, and Rust's trace level is Redis' debug level.
Configuration menu - View commit details
-
Copy full SHA for cd6458f - Browse repository at this point
Copy the full SHA cd6458fView commit details -
Merge pull request #339 from RedisLabsModules/correct-logging-mapping
Corrects the mapping of logging levels between Rust and Redis.
Configuration menu - View commit details
-
Copy full SHA for 344b256 - Browse repository at this point
Copy the full SHA 344b256View commit details -
Revert the "LogLevel" type in the root.
To preserve the API compatibility with older versions, it is necessary to allow to continue using the old "LogLevel" type. This commit brings it back but not as a enum as it had been before it changed, but as a type alias to the new enum. It also marks it as deprecated with a hint.
Configuration menu - View commit details
-
Copy full SHA for 6162e35 - Browse repository at this point
Copy the full SHA 6162e35View commit details -
Merge pull request #341 from RedisLabsModules/fix-api-compatibility
Revert the "LogLevel" type in the root.
Configuration menu - View commit details
-
Copy full SHA for 283c7a7 - Browse repository at this point
Copy the full SHA 283c7a7View commit details
Commits on Jun 1, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 810aa7c - Browse repository at this point
Copy the full SHA 810aa7cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0acedb5 - Browse repository at this point
Copy the full SHA 0acedb5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7073981 - Browse repository at this point
Copy the full SHA 7073981View commit details
Commits on Jun 6, 2023
-
The PR add support for blocking
RM_Call
. (#333)The [blocking `RM_Call`](redis/redis#11568) was introduce on Redis 7.2. The idea is to give a module writer the ability to perform blocking commands like `BLPOP` using `RM_Call`. This PR adds this functionality to `redismodule-rs`. In order to be able to invoke blocking commands, the user need to use `call_blocking` instead of `call` or `call_ext`. `call_blocking` will return an enum that can either be a regular reply (like `call_ext` returns) or it can be a `FutureCallReply`. The `FutureCallReply` can be used to set `on_done_handler` that will be called when the command gets unblock. The `on_done_handler` gets the command reply as an input. The `FutureCallReply` not outlive the `Context` that was used to invoke the blocking command. This is because the `on_done_handler` must be set before the Redis GIL is released. This restriction forces it. After setting the unblock handler, the user will get a `FutureHandler` object that can be use to abort the command invocation. The abort is done base on a best effort approach. And important details is that the `FutureHandler` must be freed when Redis GIL is held, this is why we introduce a `dispose` function (that gets a lock indicator) and not counting on `Drop` implementation. A simple usage example: ```rust fn call_blocking(ctx: &Context, _: Vec<RedisString>) -> RedisResult { // create blocking call options let call_options = CallOptionsBuilder::new().build_blocking(); // call the blocking command let res = ctx.call_blocking("blpop", &call_options, &["list", "1"]); // check the reply, if its a future, block the client until the // future is resolved. match res { PromiseCallReply::Resolved(r) => r.map_or_else(|e| Err(e.into()), |v| Ok((&v).into())), PromiseCallReply::Future(f) => { let blocked_client = ctx.block_client(); f.set_unblock_handler(move |_ctx, reply| { let thread_ctx = ThreadSafeContext::with_blocked_client(blocked_client); thread_ctx.reply(reply.map_or_else(|e| Err(e.into()), |v| Ok((&v).into()))); }); Ok(RedisValue::NoReply) } } } ``` **Notice** a nice possible improvement would be to integrate this feature with rust async await. We leave this for future PR. **Notice** The PR also updates the `redismodule.h` file.
Configuration menu - View commit details
-
Copy full SHA for 4eb77dc - Browse repository at this point
Copy the full SHA 4eb77dcView commit details
Commits on Jun 12, 2023
-
Added config changes server event (#343)
Added config changes server event
Configuration menu - View commit details
-
Copy full SHA for 4f82bce - Browse repository at this point
Copy the full SHA 4f82bceView commit details
Commits on Jun 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 736597e - Browse repository at this point
Copy the full SHA 736597eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3344c15 - Browse repository at this point
Copy the full SHA 3344c15View commit details
Commits on Jun 18, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 191f218 - Browse repository at this point
Copy the full SHA 191f218View commit details
Commits on Jun 19, 2023
-
Added cron server event. (#349)
* Added cron server event. The cron server event will be called whenever Redis runs its cron jobs (usually a few times per second). Example: ```rust #[cron_event_handler] fn cron_event_handler(ctx: &Context, hz: u64) { // run some code here that should run periodically. } ```
Configuration menu - View commit details
-
Copy full SHA for 732b2bc - Browse repository at this point
Copy the full SHA 732b2bcView commit details
Commits on Jun 20, 2023
-
Allow lock Redis from global detached context. (#350)
Allow lock Redis from global detached context. Sometimes we need to perfrom operation on Redis from a background thread, for this we need to lock Redis. We can use `ThreadSafeContext` but we might prefer not to for the following reasons: 1. Creating a `ThreadSafeContext` is costly. 2. `ThreadSafeContext` which is not attached to a client do not have the module pointer and this could cause some operations to fail. The PR adds the ability to lock Redis using the global detached context. After locking, we will get `DetachedContextGuard` object which will automatically unlock Redis when dispose. `DetachedContextGuard` implements `Deref<Context>` so it can be used just like a regular `Context` to perform operations. **Notice: This context should not be use to return any replies!!!** Future improvement is to seperate contexts for command invocation and replies so those can not be accidently misstaken, notice that this PR do not introduce any regression regarding this topic because we already have this issue with `ThreadSafeContext`.
Configuration menu - View commit details
-
Copy full SHA for 9fe7eac - Browse repository at this point
Copy the full SHA 9fe7eacView commit details
Commits on Jun 26, 2023
-
Remove module name from log info and warning log messages (#353)
* Remove module name from log info and warning log messages * Review fixes
Configuration menu - View commit details
-
Copy full SHA for eefacd3 - Browse repository at this point
Copy the full SHA eefacd3View commit details
Commits on Jul 6, 2023
-
Fix lifetime warning in Rust 1.70 (#352)
* Fix lifetime warning in Rust 1.70 Starting with rustc 1.70.0, the code in raw.rs:hash_get_multi produced the following warnings: this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime While it would work in practice due to the underlying implementation just doing pointer juggling, this warning was correct: The CString created within the macro `f` would be destroyed before the reference to the pointer taken from it with `as_ptr` was used. Resolved by binding the lifetime of the CStrings to that of the iterator variable, which is alive until the function returns. * Proper fix this time (hopefully)
Configuration menu - View commit details
-
Copy full SHA for d1f567f - Browse repository at this point
Copy the full SHA d1f567fView commit details
Commits on Jul 17, 2023
-
Improves the info handler API.
The info handler is a function which is invoked in order to handle an "INFO" command call of Redis. This call, when the module name is specified, is redirected to the module's handler function. This commit brings some user-experience improvements for the handler implementation: 1. A possibility to build a response from a struct using a derive. 2. A possibility to use a `InfoContextBuilder` facility which conveniently wraps the API to enable/disable certain code paths of the Redis API so, that it is possible to use it the correct way only.
Configuration menu - View commit details
-
Copy full SHA for 08e7c4e - Browse repository at this point
Copy the full SHA 08e7c4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for b86b07a - Browse repository at this point
Copy the full SHA b86b07aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 43a2551 - Browse repository at this point
Copy the full SHA 43a2551View commit details -
Configuration menu - View commit details
-
Copy full SHA for bc215ec - Browse repository at this point
Copy the full SHA bc215ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 458efc2 - Browse repository at this point
Copy the full SHA 458efc2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9cbc3ba - Browse repository at this point
Copy the full SHA 9cbc3baView commit details -
Revert the previous info argument of redis_module! macro.
The argument was optional and it is reverted to avoid the breaking changes. The way the macro is handled according to the new changes. The wrapping function should be inlined.
Configuration menu - View commit details
-
Copy full SHA for d6bb9cc - Browse repository at this point
Copy the full SHA d6bb9ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b87423 - Browse repository at this point
Copy the full SHA 6b87423View commit details
Commits on Jul 18, 2023
-
Split the info example into two.
This should help to confirm we still support the old way of using redis_module! macro too.
Configuration menu - View commit details
-
Copy full SHA for 87a128e - Browse repository at this point
Copy the full SHA 87a128eView commit details -
Configuration menu - View commit details
-
Copy full SHA for be7fc5f - Browse repository at this point
Copy the full SHA be7fc5fView commit details -
Configuration menu - View commit details
-
Copy full SHA for ff8a03d - Browse repository at this point
Copy the full SHA ff8a03dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4e9ccd7 - Browse repository at this point
Copy the full SHA 4e9ccd7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d8b072 - Browse repository at this point
Copy the full SHA 7d8b072View commit details
Commits on Jul 19, 2023
-
Don't stop adding sections on the first error.
The "error" might be returned when a section is attempted to be added and the user specified other sections instead.
Configuration menu - View commit details
-
Copy full SHA for 4a67005 - Browse repository at this point
Copy the full SHA 4a67005View commit details -
Configuration menu - View commit details
-
Copy full SHA for 334f06b - Browse repository at this point
Copy the full SHA 334f06bView commit details -
Merge pull request #355 from RedisLabsModules/improve-the-info-handler
Improves the info handler API.
Configuration menu - View commit details
-
Copy full SHA for 96f814b - Browse repository at this point
Copy the full SHA 96f814bView commit details
Commits on Jul 25, 2023
-
Force post notification job callback to static lifetime (#357)
Post notification job callback is kept by Redis for unknown time and so we must force it live for the static lifetime. Notice that this does not mean that the value must live forever, it just means that it can not hold any none static references. For more information: https://practice.rs/lifetime/static.html#t-static
Configuration menu - View commit details
-
Copy full SHA for e791067 - Browse repository at this point
Copy the full SHA e791067View commit details
Commits on Aug 8, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9822702 - Browse repository at this point
Copy the full SHA 9822702View commit details -
Configuration menu - View commit details
-
Copy full SHA for bc1336c - Browse repository at this point
Copy the full SHA bc1336cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 185bced - Browse repository at this point
Copy the full SHA 185bcedView commit details -
Merge pull request #359 from RedisLabsModules/add-debug-implementations
Add a Debug trait implementation for AclPermissions.
Configuration menu - View commit details
-
Copy full SHA for 12ba3dd - Browse repository at this point
Copy the full SHA 12ba3ddView commit details
Commits on Sep 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for c4ed931 - Browse repository at this point
Copy the full SHA c4ed931View commit details
There are no files selected for viewing
This file was deleted.