Module pgdo::coordinate
source · Expand description
Safely coordinate use of things that can be controlled.
For example, if many concurrent processes want to make use of the same
cluster, e.g. as part of a test suite, you can use run_and_stop to
safely start and use the cluster, then stop it when it’s no longer needed:
let cluster_dir = tempfile::tempdir()?;
let data_dir = cluster_dir.path().join("data");
let strategy = runtime::strategy::Strategy::default();
let cluster = cluster::Cluster::new(&data_dir, strategy)?;
let lock_file = cluster_dir.path().join("lock");
let lock = lock::UnlockedFile::try_from(lock_file.as_path())?;
assert!(coordinate::run_and_stop(&cluster, &[], lock, || cluster::exists(&cluster))?);Modules§
Enums§
Traits§
- The trait that these coordinate functions work with.
Functions§
- Perform
actioninsubject, destroying the subject before returning. - Perform
actioninsubject. - Perform
actioninsubjectif it exists.