Add local KV store commands

This commit is contained in:
Eric Wendland 2026-05-16 21:52:35 +02:00
commit 1a0f1e7671
14 changed files with 395 additions and 13 deletions

View file

@ -407,9 +407,10 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
CasCommand::Cleanup { dry_run } => ControlRequest::CasCleanup { dry_run },
CasCommand::List => ControlRequest::CasList,
},
Command::Kv { command } => ControlRequest::ModuleStub {
module: "kv".to_owned(),
command: format!("{command:?}"),
Command::Kv { command } => match command {
KvCommand::Create { name } => ControlRequest::KvCreate { name },
KvCommand::Set { name, key, value } => ControlRequest::KvSet { name, key, value },
KvCommand::Get { name, key } => ControlRequest::KvGet { name, key },
},
Command::Pubsub { command } => ControlRequest::ModuleStub {
module: "pubsub".to_owned(),
@ -766,6 +767,22 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
println!("schema_metadata: {}", db.schema_metadata);
println!("sync_status: {}", db.sync_status);
}
ControlResponse::KvCreated { kv } => {
println!("created kv: {}", kv.name);
println!("id: {}", kv.id);
println!("resource: {}", kv.resource);
println!("sync_status: {}", kv.sync_status);
}
ControlResponse::KvSet { entry } => {
println!("set {} {}", entry.store, entry.key);
}
ControlResponse::KvGet { entry } => {
if let Some(entry) = entry {
println!("{}", entry.value);
} else {
println!("not found");
}
}
ControlResponse::NotImplemented { module, command } => {
println!("{module} {command}: not implemented yet");
}