Skip to content
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

Latency help #89

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
@@ -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,
/// # 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.
///
12 changes: 12 additions & 0 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
@@ -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<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]