Skip to main content

with_commit_actor

Function with_commit_actor 

Source
pub async fn with_commit_actor<T, F, Fut>(
    metadata_path: &Path,
    commit: F,
) -> StorageResult<T>
where F: FnOnce() -> Fut, Fut: Future<Output = StorageResult<T>>,
Expand description

Runs commit (a full metadata read-modify-write cycle) under the metadata path’s commit actor: at most one cycle runs at a time for the same path within this process.

Public for downstream consumers (#100): any code that performs its own load → mutate → publish cycle over a metadata file outside the save_* registry paths routes the whole cycle through this function with the same metadata_path the storage instance uses, so cycles from both sides are serialized against each other. Cross-process arbitration is a separate concern — wrap the cycle in with_file_lock (see the module docs for the recipe).