Struct postgresfixture::cluster::Cluster
source · pub struct Cluster { /* private fields */ }
Expand description
Representation of a PostgreSQL cluster.
The cluster may not yet exist on disk. It may exist but be stopped, or it
may be running. The methods here can be used to create, start, introspect,
stop, and destroy the cluster. There’s no protection against concurrent
changes to the cluster made by other processes, but the functions in the
coordinate
module may help.
Implementations§
source§impl Cluster
impl Cluster
sourcepub fn new<P: AsRef<Path>, S: RuntimeStrategy>(
datadir: P,
strategy: S
) -> Result<Self, ClusterError>
pub fn new<P: AsRef<Path>, S: RuntimeStrategy>( datadir: P, strategy: S ) -> Result<Self, ClusterError>
Represent a cluster at the given path.
sourcepub fn running(&self) -> Result<bool, ClusterError>
pub fn running(&self) -> Result<bool, ClusterError>
Check if this cluster is running.
Tries to distinguish carefully between “definitely running”, “definitely
not running”, and “don’t know”. The latter results in ClusterError
.
sourcepub fn pidfile(&self) -> PathBuf
pub fn pidfile(&self) -> PathBuf
Return the path to the PID file used in this cluster.
The PID file does not necessarily exist.
sourcepub fn logfile(&self) -> PathBuf
pub fn logfile(&self) -> PathBuf
Return the path to the log file used in this cluster.
The log file does not necessarily exist.
sourcepub fn create(&self) -> Result<bool, ClusterError>
pub fn create(&self) -> Result<bool, ClusterError>
Create the cluster if it does not already exist.
pub fn start(&self) -> Result<bool, ClusterError>
pub fn connect(&self, database: &str) -> Result<Client, ClusterError>
pub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>
pub fn exec<T: AsRef<OsStr>>( &self, database: &str, command: T, args: &[T] ) -> Result<ExitStatus, ClusterError>
pub fn databases(&self) -> Result<Vec<String>, ClusterError>
sourcepub fn createdb(&self, database: &str) -> Result<bool, ClusterError>
pub fn createdb(&self, database: &str) -> Result<bool, ClusterError>
Create the named database.