Exchange DB changes over Iroh
This commit is contained in:
parent
284207eb01
commit
20fd773a42
10 changed files with 563 additions and 15 deletions
|
|
@ -351,6 +351,12 @@ pub enum DbCommand {
|
|||
#[arg(long, default_value_t = 100)]
|
||||
limit: u32,
|
||||
},
|
||||
Sync {
|
||||
node: String,
|
||||
name: String,
|
||||
#[arg(long, default_value_t = 100)]
|
||||
limit: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -665,6 +671,7 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
after_db_version,
|
||||
limit,
|
||||
},
|
||||
DbCommand::Sync { node, name, limit } => ControlRequest::DbSync { node, name, limit },
|
||||
},
|
||||
Command::Document { command } => match command {
|
||||
DocumentCommand::Create { name } => ControlRequest::DocumentCreate { name },
|
||||
|
|
@ -1321,6 +1328,37 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
);
|
||||
}
|
||||
}
|
||||
ControlResponse::DbSynced {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
endpoint_id,
|
||||
name,
|
||||
changes_received,
|
||||
max_db_version,
|
||||
schema_match,
|
||||
allowed,
|
||||
reason,
|
||||
note,
|
||||
} => {
|
||||
if allowed {
|
||||
println!("synced db changes for {name} from {peer_node_id}");
|
||||
} else {
|
||||
println!("db sync denied by {peer_node_id}");
|
||||
}
|
||||
println!("agent: {peer_agent_id}");
|
||||
println!("endpoint: {endpoint_id}");
|
||||
println!("changes_received: {changes_received}");
|
||||
println!(
|
||||
"max_db_version: {}",
|
||||
max_db_version
|
||||
.map(|version| version.to_string())
|
||||
.unwrap_or_else(|| "none".to_owned())
|
||||
);
|
||||
println!("schema_match: {schema_match}");
|
||||
println!("allowed: {allowed}");
|
||||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::KvCreated { kv } => {
|
||||
println!("created kv: {}", kv.name);
|
||||
println!("id: {}", kv.id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue