Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: RedisLabsModules/redismodule-rs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.1
Choose a base ref
...
head repository: RedisLabsModules/redismodule-rs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: refs/heads/master
Choose a head ref

Commits on May 4, 2023

  1. Fix publish CI (#323)

    toml-editor can only set strings value. This is good enough for us because we do not really need the path argument.
    MeirShpilraien authored May 4, 2023
    Copy the full SHA
    32c2925 View commit details
  2. Fix publish CI. (#324)

    Added extra-traits feature to syn dependency so we will get the Debug trait implementation.
    MeirShpilraien authored May 4, 2023
    Copy the full SHA
    02c1ab3 View commit details
  3. 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.
    iddm committed May 4, 2023
    Copy the full SHA
    409e17e View commit details

Commits on May 11, 2023

  1. Copy the full SHA
    de65b4e View commit details
  2. Merge pull request #318 from RedisLabsModules/add-logging-implementation

    Provide the standard logging facility implementation.
    iddm authored May 11, 2023
    Copy the full SHA
    2cba2be View commit details
  3. Use BTreeMap and BTreeSet in addition to HashMap and HashSet. (

    …#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.
    MeirShpilraien authored May 11, 2023
    Copy the full SHA
    82c4753 View commit details

Commits on May 15, 2023

  1. 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).
    MeirShpilraien authored May 15, 2023
    Copy the full SHA
    3ce2351 View commit details
  2. 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.
    MeirShpilraien authored May 15, 2023
    Copy the full SHA
    0c708c5 View commit details

Commits on May 21, 2023

  1. Copy the full SHA
    4306b65 View commit details

Commits on May 22, 2023

  1. 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
    ```
    MeirShpilraien authored May 22, 2023
    Copy the full SHA
    b0939e7 View commit details
  2. Copy the full SHA
    576e20d View commit details

Commits on May 23, 2023

  1. 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 
          }
          ```
    MeirShpilraien authored May 23, 2023
    Copy the full SHA
    e1bffe3 View commit details
  2. 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.
    iddm committed May 23, 2023
    Copy the full SHA
    cd6458f View commit details
  3. Merge pull request #339 from RedisLabsModules/correct-logging-mapping

    Corrects the mapping of logging levels between Rust and Redis.
    iddm authored May 23, 2023
    Copy the full SHA
    344b256 View commit details
  4. 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.
    iddm committed May 23, 2023
    Copy the full SHA
    6162e35 View commit details
  5. Merge pull request #341 from RedisLabsModules/fix-api-compatibility

    Revert the "LogLevel" type in the root.
    iddm authored May 23, 2023
    Copy the full SHA
    283c7a7 View commit details

Commits on Jun 1, 2023

  1. Copy the full SHA
    810aa7c View commit details
  2. Copy the full SHA
    0acedb5 View commit details
  3. Copy the full SHA
    7073981 View commit details

Commits on Jun 6, 2023

  1. 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.
    MeirShpilraien authored Jun 6, 2023
    Copy the full SHA
    4eb77dc View commit details

Commits on Jun 12, 2023

  1. Added config changes server event (#343)

    Added config changes server event
    MeirShpilraien authored Jun 12, 2023
    Copy the full SHA
    4f82bce View commit details

Commits on Jun 13, 2023

  1. Fix arm build (#344)

    MeirShpilraien authored Jun 13, 2023
    Copy the full SHA
    736597e View commit details
  2. Copy the full SHA
    3344c15 View commit details

Commits on Jun 18, 2023

  1. Copy the full SHA
    191f218 View commit details

Commits on Jun 19, 2023

  1. 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.
    }
    ```
    MeirShpilraien authored Jun 19, 2023
    Copy the full SHA
    732b2bc View commit details

Commits on Jun 20, 2023

  1. 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`.
    MeirShpilraien authored Jun 20, 2023
    Copy the full SHA
    9fe7eac View commit details

Commits on Jun 26, 2023

  1. Remove module name from log info and warning log messages (#353)

    * Remove module name from log info and warning log messages
    
    * Review fixes
    MeirShpilraien authored Jun 26, 2023
    Copy the full SHA
    eefacd3 View commit details

Commits on Jul 6, 2023

  1. 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)
    slavak authored Jul 6, 2023
    Copy the full SHA
    d1f567f View commit details

Commits on Jul 17, 2023

  1. 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.
    iddm committed Jul 17, 2023
    Copy the full SHA
    08e7c4e View commit details
  2. Copy the full SHA
    b86b07a View commit details
  3. Copy the full SHA
    43a2551 View commit details
  4. Correct the documentation

    iddm committed Jul 17, 2023
    Copy the full SHA
    bc215ec View commit details
  5. Refactor the supported maps list

    iddm committed Jul 17, 2023
    Copy the full SHA
    458efc2 View commit details
  6. Copy the full SHA
    9cbc3ba View commit details
  7. 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.
    iddm committed Jul 17, 2023
    Copy the full SHA
    d6bb9cc View commit details
  8. Copy the full SHA
    6b87423 View commit details

Commits on Jul 18, 2023

  1. Split the info example into two.

    This should help to confirm we still support the old way of using
    redis_module! macro too.
    iddm committed Jul 18, 2023
    Copy the full SHA
    87a128e View commit details
  2. Copy the full SHA
    be7fc5f View commit details
  3. Copy the full SHA
    ff8a03d View commit details
  4. Copy the full SHA
    4e9ccd7 View commit details
  5. Add multiple sections test

    iddm committed Jul 18, 2023
    Copy the full SHA
    7d8b072 View commit details

Commits on Jul 19, 2023

  1. 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.
    iddm committed Jul 19, 2023
    Copy the full SHA
    4a67005 View commit details
  2. Copy the full SHA
    334f06b View commit details
  3. Merge pull request #355 from RedisLabsModules/improve-the-info-handler

    Improves the info handler API.
    iddm authored Jul 19, 2023
    Copy the full SHA
    96f814b View commit details

Commits on Jul 25, 2023

  1. 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
    MeirShpilraien authored Jul 25, 2023
    Copy the full SHA
    e791067 View commit details

Commits on Aug 8, 2023

  1. Copy the full SHA
    9822702 View commit details
  2. Copy the full SHA
    bc1336c View commit details
  3. Add "Debug" to the context.

    iddm committed Aug 8, 2023
    Copy the full SHA
    185bced View commit details
  4. Merge pull request #359 from RedisLabsModules/add-debug-implementations

    Add a Debug trait implementation for AclPermissions.
    iddm authored Aug 8, 2023
    Copy the full SHA
    12ba3dd View commit details

Commits on Sep 13, 2023

  1. wip

    DvirDukhan committed Sep 13, 2023
    Copy the full SHA
    c4ed931 View commit details
Showing with 5,029 additions and 998 deletions.
  1. +0 −317 .circleci/config.yml
  2. +87 −0 .github/workflows/ci.yml
  3. +1 −1 .github/workflows/cratesio-publish.yml
  4. +0 −30 .github/workflows/freebsd.yml
  5. +3 −1 .gitignore
  6. +38 −7 Cargo.toml
  7. +0 −96 Makefile
  8. +1 −1 build.sh
  9. +314 −0 deny.toml
  10. +0 −1 deps/readies
  11. +5 −4 examples/acl.rs
  12. +1 −1 examples/block.rs
  13. +51 −3 examples/call.rs
  14. +1 −1 examples/configuration.rs
  15. +1 −1 examples/ctx_flags.rs
  16. +78 −4 examples/data_type.rs
  17. +13 −4 examples/events.rs
  18. +30 −0 examples/expire.rs
  19. +1 −1 examples/hello.rs
  20. +1 −1 examples/info.rs
  21. +27 −0 examples/info_handler_builder.rs
  22. +22 −0 examples/info_handler_macro.rs
  23. +37 −0 examples/info_handler_multiple_sections.rs
  24. +32 −0 examples/info_handler_struct.rs
  25. +1 −1 examples/keys_pos.rs
  26. +1 −1 examples/lists.rs
  27. +3 −3 examples/load_unload.rs
  28. +66 −0 examples/open_key_with_flags.rs
  29. +136 −0 examples/proc_macro_commands.rs
  30. +7 −7 examples/response.rs
  31. +1 −1 examples/scan_keys.rs
  32. +29 −2 examples/server_events.rs
  33. +1 −1 examples/stream.rs
  34. +2 −2 examples/string.rs
  35. +6 −7 examples/test_helper.rs
  36. +4 −4 examples/threads.rs
  37. +3 −3 examples/timer.rs
  38. +1 −1 redismodule-rs-macros-internals/Cargo.toml
  39. +5 −0 redismodule-rs-macros-internals/src/api_versions.rs
  40. +1 −1 redismodule-rs-macros-internals/src/lib.rs
  41. +3 −0 redismodule-rs-macros/Cargo.toml
  42. +403 −0 redismodule-rs-macros/src/command.rs
  43. +109 −0 redismodule-rs-macros/src/info_section.rs
  44. +467 −0 redismodule-rs-macros/src/lib.rs
  45. +146 −0 redismodule-rs-macros/src/redis_value.rs
  46. +0 −24 sbin/setup
  47. +0 −56 sbin/system-setup.py
  48. +1 −1 src/alloc.rs
  49. +160 −21 src/context/call_reply.rs
  50. +520 −0 src/context/commands.rs
  51. +247 −0 src/context/defrag.rs
  52. +703 −34 src/context/mod.rs
  53. +68 −1 src/context/server_events.rs
  54. +130 −22 src/include/redismodule.h
  55. +67 −20 src/key.rs
  56. +67 −26 src/lib.rs
  57. +163 −20 src/logging.rs
  58. +134 −12 src/macros.rs
  59. +3 −13 src/native_types.rs
  60. +96 −5 src/raw.rs
  61. +11 −4 src/redismodule.rs
  62. +86 −2 src/redisvalue.rs
  63. +2 −0 src/stream.rs
  64. +1 −1 test.sh
  65. +385 −136 tests/integration.rs
  66. +46 −0 tests/utils.rs
  67. +0 −92 unused/hello_no_macros.rs
317 changes: 0 additions & 317 deletions .circleci/config.yml

This file was deleted.

Loading