From 31334b652521d629424493fe532fa8f8dfa713c9 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 4 Jul 2022 12:10:30 +0200 Subject: [PATCH 1/2] Add `poll` command to `k2v-cli` --- src/k2v-client/bin/k2v-cli.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs index 38c39361..b43d849a 100644 --- a/src/k2v-client/bin/k2v-cli.rs +++ b/src/k2v-client/bin/k2v-cli.rs @@ -55,6 +55,19 @@ enum Command { #[clap(flatten)] output_kind: ReadOutputKind, }, + /// Watch changes on a single value + Poll { + /// Partition key to delete from + partition_key: String, + /// Sort key to delete from + sort_key: String, + /// Causality information + #[clap(short, long)] + causality: String, + /// Output formating + #[clap(flatten)] + output_kind: ReadOutputKind, + }, /// Delete a single value Delete { /// Partition key to delete from @@ -324,6 +337,19 @@ async fn main() -> Result<(), Error> { let res = client.read_item(&partition_key, &sort_key).await?; output_kind.display_output(res); } + Command::Poll { + partition_key, + sort_key, + causality, + output_kind, + } => { + let res_opt = client.poll_item(&partition_key, &sort_key, causality.into(), None).await?; + if let Some(res) = res_opt { + output_kind.display_output(res); + } else { + println!("Delay expired and value didn't change."); + } + } Command::ReadIndex { output_kind, filter, -- 2.43.4 From 79f524f1bb80f72bcc4013dd3b8dcd2d85234fd5 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 4 Jul 2022 12:11:47 +0200 Subject: [PATCH 2/2] cargo fmt --- src/k2v-client/bin/k2v-cli.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs index b43d849a..884e7438 100644 --- a/src/k2v-client/bin/k2v-cli.rs +++ b/src/k2v-client/bin/k2v-cli.rs @@ -343,7 +343,9 @@ async fn main() -> Result<(), Error> { causality, output_kind, } => { - let res_opt = client.poll_item(&partition_key, &sort_key, causality.into(), None).await?; + let res_opt = client + .poll_item(&partition_key, &sort_key, causality.into(), None) + .await?; if let Some(res) = res_opt { output_kind.display_output(res); } else { -- 2.43.4