-
Notifications
You must be signed in to change notification settings - Fork 67
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
Conversation
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`
bf8d44b
to
f3661da
Compare
Thanks @vityafx I believe I addressed all comments. Please take another look to make sure I did not miss anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 !
Thanks, will wait for this one to merge as it is depends on it: #280 |
@vityafx the last commit are only conflicts fixes |
There was a problem hiding this 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.
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
Main changes:
&[u8]
instead of&str
because key name can be binary.RedisError
or general message so we can return this error type even without having an actualRedisModuleCallReply
error.DetachContext
struct which implementsSync
andSend
. 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 correctRedisModuleAPI
.ThreadSafeContext
lock function was fixed to avoid reuse the context and avoid duplicate context free.RedisModule_Init
was split toRedisModule_Init
andRedisModule_InitAPI
so we can initialise the API without register a module. This is usefull for modules that load more plugins and want to initialise theRedisModuleAPI
on the plugin but without Register it as a another module. We should consider back-port this change to Redis.init_func
callback after finish registration of commands and configuration so configuration value will be applied when called.safe_clone
forRedisModuleString
. In generalRedisModuleString
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.RedisString
module_args_as_configuration
option to work correctly on imutable configurations.Depends on: #280