-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support for DEBUG DIGEST module data type callback #21
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4edc19c
Support for DEBUG DIGEST module data type callback
nnmehta 743516d
Update test cases
nnmehta 988f056
Move digest to wrapper
nnmehta cba8f17
Update tests
nnmehta 0232f2d
Add more scenarios for debug test
nnmehta dc303c1
Clean code and add scenario for debug test
nnmehta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use std::os::raw::c_char; | ||
use valkey_module::raw; | ||
use valkey_module::ValkeyString; | ||
|
||
/// `Digest` is a high-level rust interface to the Valkey module C API | ||
/// abstracting away the raw C ffi calls. | ||
pub struct Digest { | ||
pub dig: *mut raw::RedisModuleDigest, | ||
} | ||
|
||
impl Digest { | ||
pub const fn new(dig: *mut raw::RedisModuleDigest) -> Self { | ||
Self { dig } | ||
} | ||
|
||
/// Returns the key name of this [`Digest`]. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `RedisModule_GetKeyNameFromDigest` is missing in redismodule.h | ||
pub fn get_key_name(&self) -> ValkeyString { | ||
ValkeyString::from_redis_module_string(std::ptr::null_mut(), unsafe { | ||
raw::RedisModule_GetKeyNameFromDigest | ||
.expect("RedisModule_GetKeyNameFromDigest is not available.")(self.dig) | ||
.cast_mut() | ||
}) | ||
} | ||
|
||
/// Returns the database ID of this [`Digest`]. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `RedisModule_GetDbIdFromDigest` is missing in redismodule.h | ||
pub fn get_db_id(&self) -> i32 { | ||
unsafe { | ||
raw::RedisModule_GetDbIdFromDigest | ||
.expect("RedisModule_GetDbIdFromDigest is not available.")(self.dig) | ||
} | ||
} | ||
|
||
/// Adds a new element to this [`Digest`]. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `RedisModule_DigestAddStringBuffer` is missing in redismodule.h | ||
pub fn add_string_buffer(&mut self, ele: &[u8]) { | ||
unsafe { | ||
raw::RedisModule_DigestAddStringBuffer | ||
.expect("RedisModule_DigestAddStringBuffer is not available.")( | ||
self.dig, | ||
ele.as_ptr().cast::<c_char>(), | ||
ele.len(), | ||
) | ||
} | ||
} | ||
|
||
/// Similar to [`Digest::add_string_buffer`], but takes [`i64`]. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `RedisModule_DigestAddLongLong` is missing in redismodule.h | ||
pub fn add_long_long(&mut self, ll: i64) { | ||
unsafe { | ||
raw::RedisModule_DigestAddLongLong | ||
.expect("RedisModule_DigestAddLongLong is not available.")(self.dig, ll) | ||
} | ||
} | ||
|
||
/// Ends the current sequence in this [`Digest`]. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `RedisModule_DigestEndSequence` is missing in redismodule.h | ||
pub fn end_sequence(&mut self) { | ||
unsafe { | ||
raw::RedisModule_DigestEndSequence | ||
.expect("RedisModule_DigestEndSequence is not available.")(self.dig) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod bloom_callback; | ||
pub mod digest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,7 +474,7 @@ def port_tracker_fixture(self, resource_port_tracker): | |
self.port_tracker = resource_port_tracker | ||
|
||
def _get_valkey_args(self): | ||
self.args.update({"maxmemory":self.maxmemory, "maxmemory-policy":"allkeys-random", "activerehashing":"yes", "databases": self.num_dbs, "repl-diskless-sync": "yes", "save": ""}) | ||
self.args.update({"maxmemory":self.maxmemory, "maxmemory-policy":"allkeys-random", "activerehashing":"yes", "databases": self.num_dbs, "repl-diskless-sync": "yes", "save": "", "enable-debug-command":"yes"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let us also add testing in two other places:
|
||
self.args.update(self.get_custom_args()) | ||
return self.args | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Example:
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.
Sure, will add these scenarios