refactor: return persisted partition count

When calling persist_partitions(), return the number of partitions that
were persisted to the caller.
pull/24376/head
Dom Dwyer 2023-01-10 20:28:36 +01:00
parent a80e66336b
commit 23280d0489
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 6 additions and 2 deletions

View File

@ -14,12 +14,12 @@ use super::queue::PersistQueue;
const PERSIST_ENQUEUE_CONCURRENCY: usize = 5;
// Persist a set of [`PartitionData`], blocking for completion of all enqueued
// persist jobs.
// persist jobs and returning the number of partitions that were persisted.
//
// This call is not atomic, partitions are marked for persistence incrementally.
// Writes that landed into the partition buffer after this call, but before the
// partition data is read will be included in the persisted data.
pub(crate) async fn persist_partitions<T, P>(iter: T, persist: &P)
pub(crate) async fn persist_partitions<T, P>(iter: T, persist: &P) -> usize
where
T: Iterator<Item = Arc<Mutex<PartitionData>>> + Send,
P: PersistQueue + Clone,
@ -70,8 +70,12 @@ where
"queued all non-empty partitions for persist"
);
let count = notifications.len();
// Wait for all the persist completion notifications.
for n in notifications {
n.await.expect("persist worker task panic");
}
count
}