Struct pgdo::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

source

pub fn new<P: AsRef<Path>, S: Strategy>( datadir: P, strategy: S ) -> Result<Self, ClusterError>

Represent a cluster at the given path.

source

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.

source

pub fn pidfile(&self) -> PathBuf

Return the path to the PID file used in this cluster.

The PID file does not necessarily exist.

source

pub fn logfile(&self) -> PathBuf

Return the path to the log file used in this cluster.

The log file does not necessarily exist.

source

pub fn create(&self) -> Result<State, ClusterError>

Create the cluster if it does not already exist.

source

pub fn start(&self) -> Result<State, ClusterError>

Start the cluster if it’s not already running.

source

pub fn connect(&self, database: &str) -> Result<Client, ClusterError>

Connect to this cluster.

source

pub fn shell(&self, database: &str) -> Result<ExitStatus, ClusterError>

Run psql against this cluster, in the given database.

source

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.

source

pub fn databases(&self) -> Result<Vec<String>, ClusterError>

The names of databases in this cluster.

source

pub fn createdb(&self, database: &str) -> Result<(), ClusterError>

Create the named database.

source

pub fn dropdb(&self, database: &str) -> Result<(), ClusterError>

Drop the named database.

source

pub fn stop(&self) -> Result<State, ClusterError>

Stop the cluster if it’s running.

source

pub fn destroy(&self) -> Result<State, ClusterError>

Destroy the cluster if it exists, after stopping it.

Trait Implementations§

source§

impl AsRef<Path> for Cluster

source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more