Skip to content

Commit

Permalink
Latency help (#89)
Browse files Browse the repository at this point in the history
* implement high level command LATENCY HELP

* remove extra imports
  • Loading branch information
ArtemIsmagilov authored Dec 24, 2024
1 parent 3a678e6 commit 3ab1d4e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,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,
/// # 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<String> = client.latency_help().await?;
/// assert!(result.iter().any(|e| e == "HELP"));
/// # Ok(())
/// # }
/// ```
/// # See Also
/// [<https://redis.io/commands/latency-help/>](https://redis.io/commands/latency-help/)
fn latency_help(self) -> PreparedCommand<'a, Self, Vec<String>>
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.
///
Expand Down
12 changes: 12 additions & 0 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,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<String> = 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]
Expand Down

0 comments on commit 3ab1d4e

Please sign in to comment.