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: Into<Strategy>>(
datadir: P,
strategy: S
) -> Result<Self, ClusterError>
pub fn new<P: AsRef<Path>, S: Into<Strategy>>( 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<State, ClusterError>
pub fn create(&self) -> Result<State, ClusterError>
Create the cluster if it does not already exist.
sourcepub fn start(&self) -> Result<State, ClusterError>
pub fn start(&self) -> Result<State, ClusterError>
Start the cluster if it’s not already running.
sourcepub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>
pub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>
Run psql
against this cluster, in the given database.
sourcepub fn exec<T: AsRef<OsStr>>(
&self,
database: &str,
command: T,
args: &[T]
) -> Result<ExitStatus, ClusterError>
pub fn exec<T: AsRef<OsStr>>( &self, database: &str, command: T, args: &[T] ) -> Result<ExitStatus, ClusterError>
Run the given command against this cluster.
The command is run with the PGDATA
, PGHOST
, and PGDATABASE
environment variables set appropriately.
sourcepub fn databases(&self) -> Result<Vec<String>, ClusterError>
pub fn databases(&self) -> Result<Vec<String>, ClusterError>
The names of databases in this cluster.
sourcepub fn stop(&self) -> Result<State, ClusterError>
pub fn stop(&self) -> Result<State, ClusterError>
Stop the cluster if it’s running.
sourcepub fn destroy(&self) -> Result<State, ClusterError>
pub fn destroy(&self) -> Result<State, ClusterError>
Destroy the cluster if it exists, after stopping it.