Live sync KV stores over Iroh
This commit is contained in:
parent
68153be5d5
commit
f85039367c
9 changed files with 473 additions and 13 deletions
|
|
@ -304,6 +304,10 @@ pub enum KvCommand {
|
|||
name: String,
|
||||
key: String,
|
||||
},
|
||||
Sync {
|
||||
node: String,
|
||||
name: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -617,6 +621,7 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
subject,
|
||||
},
|
||||
KvCommand::Get { name, key } => ControlRequest::KvGet { name, key },
|
||||
KvCommand::Sync { node, name } => ControlRequest::KvSync { node, name },
|
||||
},
|
||||
Command::Pubsub { command } => match command {
|
||||
PubsubCommand::Pub { topic, message } => ControlRequest::PubsubPub { topic, message },
|
||||
|
|
@ -1309,6 +1314,27 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("not found");
|
||||
}
|
||||
}
|
||||
ControlResponse::KvSynced {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
endpoint_id,
|
||||
name,
|
||||
entries_imported,
|
||||
allowed,
|
||||
reason,
|
||||
note,
|
||||
} => {
|
||||
if allowed {
|
||||
println!("synced kv {name} from {peer_node_id}: {entries_imported} entries");
|
||||
} else {
|
||||
println!("kv sync denied for {name} by {peer_node_id}");
|
||||
}
|
||||
println!("agent: {peer_agent_id}");
|
||||
println!("endpoint: {endpoint_id}");
|
||||
println!("allowed: {allowed}");
|
||||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::DocumentCreated { document } => {
|
||||
println!("created document: {}", document.name);
|
||||
println!("id: {}", document.id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue