-
Notifications
You must be signed in to change notification settings - Fork 65
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
API extentions. #229
base: master
Are you sure you want to change the base?
API extentions. #229
Conversation
1. Cursor API to scan the key space 2. Stream API * Read range from streams * Trim stream 3. Server Events API to register to the following events: * Flush started/ended * Loading started/ended for AOF/RDB/Replication * Role changed (become primary/replica) 4. Is primary API was added to Context object
8541ac9
to
325f4ca
Compare
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.
👏🏼 💪🏼 Some questions
|
||
let stream_key = args.next_arg()?; | ||
|
||
let stream = ctx.open_key(&stream_key); |
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 making sure - could also test for null
here but can also skip this test since it is also handled in key_type()
(since the common usage would not be a missing key, it would be better to skip a null
test here and let key_type()
handle nulls)
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.
Yes, key_type should verify it.
let num_loading = unsafe { &mut NUM_LOADINGS }; | ||
*num_loading = *num_loading + 1; |
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.
Seems equivalently unsafe as
unsafe {NUM_LOADINGS += 1};
(same with NUM_FLUSHES
and NUM_ROLED_CHANGED
)
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.
Yes, but I wanted the unsafe part to be as minimal as possible
&context, | ||
crate::redis_module::context::server_events::ServerEvents::$server_event_type, | ||
Box::new($server_event_handler))) { | ||
context.log_warning(&format!("Failed register server event, {}", err)); |
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.
Does err
include the server_event_type
so there is no need to log it?
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.
There is a relevant error on subscribe_to_server_event
.
RedisString::from_redis_module_string(self.ctx, field_val), | ||
)); | ||
} | ||
|
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.
Should we verify fields
len is indeed num_fields
?
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.
I do not see a reason to, the purpose is not to test Redis, we assume Redis has his own tests for this api.
} | ||
|
||
#[derive(Clone)] | ||
pub enum ServerEventData { |
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.
There are several more events (even with oss), for example, RedisModuleEvent_ClientChange
, RedisModuleEvent_Shutdown
, etc.
But we only support a subset now?
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.
I will add it gradually when needed.
Co-authored-by: Omer Shadmi <[email protected]>
…es and avoid crashes.
Within the macro_rules! the $crate should be used when it is required to refer to the current crate. This commit changes the referencing to the correct one.
1. Fixes the warning of the unused result. Now the result is explicitly dropped and so the intention behind the code written is clear. 2. Fixes the typo - "emmutable" to "immutable".
By deriving Ord and PartialOrd we can compare two versions easier. We need to be able to compare the versions to make sure the compatible version is used with the module.
…bility-checking Allow for easier version compatibility checking.
Such situations occur when, for example, the crate which uses the redismodule-rs crate as a dependency is run for testing, so without Redis available. In this case, there is no allocator available as well and it will lead to a panic. To enable both the situations to work correctly under all circumstances, this change introduces a fallback mechanism back to the system allocator (default Rust allocator) which is always available. Note that the changes are zero-cost: the code before this changes used unwrap() which also had checks for the value being non-null and would panic at runtime if it was null, the current code does this check as well but instead of panicking reverts back to the system allocator.
The previous code either wouldn't compile or wouldn't run due to missing assets for the tests. This commit brings changes necessary to enable the cargo test to run properly again.
Reverts the behaviour to panicking when the redis allocator isn't present. Changes the panic to avoid allocations using the specified allocator so that a meaningful message can be observed.
…allocator-when-redis-isnt-available Allow the crate to operate when the Redis API isn't available.
The backwards compatibility is broken with the old Rust due to fixing a mistake with imports. This commit uses the direct import for unix systems of the AsRawFd trait and should work on all unix systems.
Fix the backwards compatibility with old Rust.
Cursor API to scan the key space.- Added keys scan API. #265Stream API:- Added API to read and trim a stream. #266Server Events API to register to the following events:- Added API to register to server events. #267Is primary API was added to Context object.- Added API to get ctx flags. #270Key missed notification- Added keymiss event support #289Update redismodule.h to v7.0.2- cleaning clippy warnings #253Added support for context acl authentication- Adde API for ACL validation #294Added API to key acl key permission- Adde API for ACL validation #294Added API to check if server is OOM- Added API to get ctx flags. #270todo: