From ea73acb487c74124c194b3990f99d5054d7604fa Mon Sep 17 00:00:00 2001 From: ArtemIsmagilov Date: Tue, 24 Dec 2024 19:31:11 +0400 Subject: [PATCH 1/2] implement high level command LATENCY HELP --- src/commands/server_commands.rs | 31 +++++++++++++++++++++++++++++++ src/tests/server_commands.rs | 12 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/commands/server_commands.rs b/src/commands/server_commands.rs index 1d205e5..efe183a 100644 --- a/src/commands/server_commands.rs +++ b/src/commands/server_commands.rs @@ -663,6 +663,37 @@ pub trait ServerCommands<'a> { prepare_command(self, cmd("LATENCY").arg("GRAPH").arg(event)) } + /// The command returns a helpful text describing the different LATENCY subcommands. + /// + /// # Return + /// An array of strings. + /// + /// # Example + /// ``` + /// # use rustis::{ + /// # client::{Client, ClientPreparedCommand}, + /// # commands::ServerCommands, + /// # Result, + /// # }; + /// # + /// # #[cfg_attr(feature = "tokio-runtime", tokio::main)] + /// # #[cfg_attr(feature = "async-std-runtime", async_std::main)] + /// # async fn main() -> Result<()> { + /// # let client = Client::connect("127.0.0.1:6379").await?; + /// let result: Vec = client.latency_help().await?; + /// assert!(result.iter().any(|e| e == "HELP")); + /// # Ok(()) + /// # } + /// ``` + /// # See Also + /// [](https://redis.io/commands/latency-help/) + fn latency_help(self) -> PreparedCommand<'a, Self, Vec> + where + Self: Sized, + { + prepare_command(self, cmd("LATENCY").arg("HELP")) + } + /// This command reports a cumulative distribution of latencies /// in the format of a histogram for each of the specified command names. /// diff --git a/src/tests/server_commands.rs b/src/tests/server_commands.rs index 87f06dc..39ba6c4 100644 --- a/src/tests/server_commands.rs +++ b/src/tests/server_commands.rs @@ -697,6 +697,18 @@ async fn latency_graph() -> Result<()> { Ok(()) } +#[cfg_attr(feature = "tokio-runtime", tokio::test)] +#[cfg_attr(feature = "async-std-runtime", async_std::test)] +#[serial] +async fn latency_help() -> Result<()> { + let client = get_test_client().await?; + + let result: Vec = client.latency_help().await?; + assert!(result.iter().any(|e| e == "HELP")); + + Ok(()) +} + #[cfg_attr(feature = "tokio-runtime", tokio::test)] #[cfg_attr(feature = "async-std-runtime", async_std::test)] #[serial] From ff3f21c84a3aa8b85fcfdf46f9534332f27e29b5 Mon Sep 17 00:00:00 2001 From: ArtemIsmagilov Date: Tue, 24 Dec 2024 19:33:25 +0400 Subject: [PATCH 2/2] remove extra imports --- src/commands/server_commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/server_commands.rs b/src/commands/server_commands.rs index efe183a..82280b4 100644 --- a/src/commands/server_commands.rs +++ b/src/commands/server_commands.rs @@ -671,7 +671,7 @@ pub trait ServerCommands<'a> { /// # Example /// ``` /// # use rustis::{ - /// # client::{Client, ClientPreparedCommand}, + /// # client::Client, /// # commands::ServerCommands, /// # Result, /// # };