Add poll command to k2v-cli (#335)
All checks were successful
continuous-integration/drone/push Build is passing

Co-authored-by: Alex Auvolat <alex@adnab.me>
Reviewed-on: #335
Co-authored-by: Alex <alex@adnab.me>
Co-committed-by: Alex <alex@adnab.me>
This commit is contained in:
Alex 2022-07-04 12:45:32 +02:00
parent b74b533b7b
commit 0850bac874

View file

@ -55,6 +55,19 @@ enum Command {
#[clap(flatten)] #[clap(flatten)]
output_kind: ReadOutputKind, 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 a single value
Delete { Delete {
/// Partition key to delete from /// Partition key to delete from
@ -324,6 +337,21 @@ async fn main() -> Result<(), Error> {
let res = client.read_item(&partition_key, &sort_key).await?; let res = client.read_item(&partition_key, &sort_key).await?;
output_kind.display_output(res); 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 { Command::ReadIndex {
output_kind, output_kind,
filter, filter,