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

The PR introduce small API fixes/changes. #302

Merged
merged 34 commits into from
Apr 5, 2023
Merged

Conversation

MeirShpilraien
Copy link
Collaborator

@MeirShpilraien MeirShpilraien commented Apr 1, 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

@MeirShpilraien MeirShpilraien requested a review from iddm April 1, 2023 13:25
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 inplements `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.
* `autenticate_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 intialize the API without register a module. This is usefull for modules that load more plugins and want to intialize the `RedisModuleAPI` on the plugin but without Register it as a another module. We should consider backport 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 serialize and deserialize for `RedisString`
@MeirShpilraien MeirShpilraien requested a review from iddm April 3, 2023 18:40
@MeirShpilraien
Copy link
Collaborator Author

Thanks @vityafx I believe I addressed all comments. Please take another look to make sure I did not miss anything.

@MeirShpilraien MeirShpilraien requested a review from iddm April 4, 2023 11:09
iddm
iddm previously approved these changes Apr 4, 2023
Copy link
Collaborator

@iddm iddm left a comment

Choose a reason for hiding this comment

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

👍 !

@MeirShpilraien
Copy link
Collaborator Author

Thanks, will wait for this one to merge as it is depends on it: #280

Base automatically changed from gkorland-resp3-api to master April 5, 2023 10:22
@MeirShpilraien
Copy link
Collaborator Author

@vityafx the last commit are only conflicts fixes

Copy link
Collaborator

@iddm iddm left a comment

Choose a reason for hiding this comment

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

Just a few minor comments.

@MeirShpilraien MeirShpilraien merged commit 0fa0b24 into master Apr 5, 2023
@MeirShpilraien MeirShpilraien deleted the ap_fixes_changes branch April 5, 2023 11:27
MeirShpilraien added a commit that referenced this pull request Apr 24, 2023
The PR is a proposal for API versioning using feature flags.
The PR introduce 4 new feature flags:
* `min-redis-compatibility-version-7-2`
* `min-redis-compatibility-version-7-0`
* `min-redis-compatibility-version-6-2`
* `min-redis-compatibility-version-6-0` - default

User should set one of those feature flag which will indicate the minimum Redis version he want to be compatible with. Base on this, redismodule-rs will decide which API can be used and will manipulate existing API so it can be used conditionally.

For example, take the following API:
```
pub fn add_post_notification_job<F: Fn(&Context)>(self, callback: F)
```

This API require Redis version 7.2, so if `min-redis-compatibility-version-7-2` feature is set the API is exposed as is. But if some other `min-redis-compatibility-version-*` is set, the API is changed to return `APIResult` which will allow to conditionally use this API if exists on the current Redis instance.

The PR also adds support for post notifications jobs and demonstrate how to use the new `min-redis-compatibility-version-*` flags.

Depends on: #302
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.

3 participants