Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RESP3 new APIs #280

Merged
merged 26 commits into from
Apr 5, 2023
Merged

add RESP3 new APIs #280

merged 26 commits into from
Apr 5, 2023

Conversation

gkorland
Copy link
Contributor

@gkorland gkorland commented Feb 8, 2023

The PR adds Resp3 support for both, return result from module command and getting result as resp3 on ctx.call_ext (when resp3 option is used).

Tests was added to verify both new functionalities.

The PR also refactor the CallReply API introduced on #290. Instead of having 2 types of CallReply we now have one type such that the root call reply created with 'static lifetime indicating that the user can hold it for as long as it want. Internal CallReply can outlive its father.
As part of the refactoring, the CallReply was changed to be more rust friendly. CallReply was renamed to CallResult = Result<CallReply, ErrorCallReply>, CallReply is an enum which allows to check the CallReply type using a match statement.

src/redisvalue.rs Outdated Show resolved Hide resolved
src/raw.rs Outdated Show resolved Hide resolved
.with_context(|| "failed to run string.set")?;

res.sort();
assert_eq!(&res, &["a", "b", "b", "c", "d", "e"]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering how this test pass but then I notice that its not, also this client does not really check the reply is resp3 right?

@MeirShpilraien MeirShpilraien requested a review from iddm March 24, 2023 22:18
examples/call.rs Outdated Show resolved Hide resolved
examples/response.rs Show resolved Hide resolved
examples/response.rs Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Show resolved Hide resolved
src/key.rs Show resolved Hide resolved
src/raw.rs Show resolved Hide resolved
src/redisvalue.rs Outdated Show resolved Hide resolved
src/redisvalue.rs Outdated Show resolved Hide resolved
src/redisvalue.rs Outdated Show resolved Hide resolved
@MeirShpilraien
Copy link
Collaborator

@vityafx thanks for the review. I either addressed the comments or added more comments. Let me know what you think.

@MeirShpilraien MeirShpilraien requested a review from iddm March 25, 2023 20:28
examples/call.rs Show resolved Hide resolved
@MeirShpilraien MeirShpilraien requested a review from iddm April 2, 2023 09:15
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
src/context/call_reply.rs Outdated Show resolved Hide resolved
@MeirShpilraien
Copy link
Collaborator

@vityafx fixed the Debug implementation and also added Display. Let me know what you think.

src/context/call_reply.rs Outdated Show resolved Hide resolved
@MeirShpilraien MeirShpilraien requested a review from iddm April 5, 2023 09:29
iddm
iddm previously approved these changes Apr 5, 2023
src/redisvalue.rs Show resolved Hide resolved
src/redisvalue.rs Show resolved Hide resolved
@MeirShpilraien MeirShpilraien merged commit d79071c into master Apr 5, 2023
@MeirShpilraien MeirShpilraien deleted the gkorland-resp3-api branch April 5, 2023 10:22
MeirShpilraien added a commit that referenced this pull request Apr 5, 2023
Main changes:

* Key space notification API will get the keys as `&[u8]` instead of `&str` because key name can be binary.
* ErrorReply was changed to be an enum of `RedisError` or general message so we can return this error type even without having an actual `RedisModuleCallReply` error.
* Introduce `DetachContext` struct which implements `Sync` and `Send`. This can be used to create a global context for logging only.
* `replicate` can accept also binary data and not only utf8.
* `create_string` can accept binary data and not only utf8.
* `authenticate_user` implementation was fixed to use the correct `RedisModuleAPI`.
* `ThreadSafeContext` lock function was fixed to avoid reuse the context and avoid duplicate context free.
* `RedisModule_Init` was split to `RedisModule_Init` and `RedisModule_InitAPI` so we can initialise the API without register a module. This is usefull for modules that load more plugins and want to initialise the `RedisModuleAPI` on the plugin but without Register it as a another module. We should consider back-port this change to Redis.
* Move `init_func` callback after finish registration of commands and configuration so configuration value will be applied when called.
* Introduce `safe_clone` for `RedisModuleString`. In general `RedisModuleString` is none atomic ref counted object. So it is not safe to clone it if Redis GIL is not hold. `safe_clone` gets a context reference which indicating that Redis GIL is held.
* Implement serde serialise and de-serialise for `RedisString`
* Fix configuration API `module_args_as_configuration` option to work correctly on imutable configurations.
* Added option to specify module costume config get and set commands.

Depends on: #280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants