-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functions to get_client_id, name, username, info and certificate
added example and tests Signed-off-by: Dmitry Polyakovsky <[email protected]>
- Loading branch information
Dmitry Polyakovsky
committed
Feb 24, 2025
1 parent
a809633
commit 166b6f6
Showing
4 changed files
with
79 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use valkey_module::alloc::ValkeyAlloc; | ||
use valkey_module::{valkey_module, Context, ValkeyResult, ValkeyString}; | ||
|
||
valkey_module! { | ||
name: "client", | ||
version: 1, | ||
allocator: (ValkeyAlloc, ValkeyAlloc), | ||
data_types: [], | ||
commands: [ | ||
["client.id", get_client_id, "readonly", 1, 1, 1], | ||
] | ||
} | ||
|
||
fn get_client_id(ctx: &Context, _args: Vec<ValkeyString>) -> ValkeyResult { | ||
let client_id = ctx.get_client_id(); | ||
ctx.log_notice(&format!( | ||
"client_username: {:?}", | ||
ctx.get_client_username().to_string() | ||
)); | ||
ctx.log_notice(&format!( | ||
"client_name: {:?}", | ||
ctx.get_client_name().to_string() | ||
)); | ||
ctx.log_notice(&format!( | ||
"client_cert: {:?}", | ||
ctx.get_client_cert().to_string() | ||
)); | ||
ctx.log_notice(&format!("client_info: {:?}", ctx.get_client_info())); | ||
Ok((client_id as i64).into()) | ||
} |
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