Expand description

The essential functionality in this crate is in the Cluster struct and its implementation. This covers the logic you need to create, run, and destroy PostgreSQL clusters of any officially supported version (and a few older versions that are not supported upstream).

for runtime in runtime::Runtime::find_on_path() {
  let data_dir = tempdir::TempDir::new("data")?;
  let cluster = cluster::Cluster::new(&data_dir, runtime);
  assert_eq!(cluster.databases()?, vec!["postgres", "template0", "template1"]);
  let mut conn = cluster.connect("template1")?;
  let rows = conn.query("SELECT 1234 -- …", &[])?;
  let collations: Vec<i32> = rows.iter().map(|row| row.get(0)).collect();
  assert_eq!(collations, vec![1234]);

You may want to use this with the functions in the coordinate module like run_and_stop and run_and_destroy. These add locking to the setup and teardown steps of using a cluster so that multiple processes can safely share a single on-demand cluster.


Create, start, introspect, stop, and destroy PostgreSQL clusters.

Safely coordinate use of Cluster.

File-based locking using flock(2).

Discover and use PostgreSQL installations.

Parse PostgreSQL version numbers.