Expand description

Safely coordinate use of Cluster.

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:

use postgresfixture::prelude::*;
let cluster_dir = tempdir::TempDir::new("cluster")?;
let data_dir = cluster_dir.path().join("data");
let runtime = strategy::default();
let cluster = Cluster::new(&data_dir, runtime)?;
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)?);

Functions