add num_local_operations to Replica

This commit is contained in:
Dustin J. Mitchell
2022-04-23 18:51:40 +00:00
parent 6f8c734186
commit fd504b7d66
5 changed files with 30 additions and 0 deletions

View File

@@ -257,6 +257,12 @@ impl<'t> StorageTxn for Txn<'t> {
Ok(ret)
}
fn num_operations(&mut self) -> anyhow::Result<usize> {
let t = self.get_txn()?;
let count: usize = t.query_row("SELECT count(*) FROM operations", [], |x| x.get(0))?;
Ok(count)
}
fn add_operation(&mut self, op: ReplicaOp) -> anyhow::Result<()> {
let t = self.get_txn()?;
@@ -627,6 +633,8 @@ mod test {
ReplicaOp::Create { uuid: uuid2 },
]
);
assert_eq!(txn.num_operations()?, 2);
}
// set them to a different bunch
@@ -678,6 +686,7 @@ mod test {
},
]
);
assert_eq!(txn.num_operations()?, 4);
}
Ok(())
}