Expose db change batches over control

This commit is contained in:
Eric Wendland 2026-05-17 20:32:36 +02:00
commit a44eef3126
8 changed files with 130 additions and 15 deletions

View file

@ -248,8 +248,20 @@ pub enum PipeCommand {
#[derive(Debug, Subcommand)]
pub enum DbCommand {
Add { name: String, path: PathBuf },
Status { name: String },
Add {
name: String,
path: PathBuf,
},
Status {
name: String,
},
Changes {
name: String,
#[arg(long)]
after_db_version: Option<i64>,
#[arg(long, default_value_t = 100)]
limit: u32,
},
}
#[derive(Debug, Subcommand)]
@ -469,6 +481,15 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
Command::Db { command } => match command {
DbCommand::Add { name, path } => ControlRequest::DbAdd { name, path },
DbCommand::Status { name } => ControlRequest::DbStatus { name },
DbCommand::Changes {
name,
after_db_version,
limit,
} => ControlRequest::DbChanges {
name,
after_db_version,
limit,
},
},
Command::Document { command } => match command {
DocumentCommand::Create { name } => ControlRequest::DocumentCreate { name },
@ -893,6 +914,24 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
}
println!("sync_status: {}", db.sync_status);
}
ControlResponse::DbChanges { db, batch } => {
println!("db: {}", db.name);
println!("changes: {}", batch.changes.len());
println!(
"max_db_version: {}",
batch
.max_db_version
.map(|version| version.to_string())
.unwrap_or_else(|| "none".to_owned())
);
println!("schema_metadata: {}", batch.schema_metadata);
for change in batch.changes {
println!(
"{}\t{}\t{}",
change.db_version, change.table_name, change.column_id
);
}
}
ControlResponse::KvCreated { kv } => {
println!("created kv: {}", kv.name);
println!("id: {}", kv.id);