Skip to main content

Pool

Struct Pool 

Source
pub struct Pool<C = Client> { /* private fields */ }
Expand description

The connections of a process to its homes’ services, one per home (Pool::new: real Clients; a test hands its own connection type to Pool::with).

Implementations§

Source§

impl Pool<Client>

Source

pub fn new(binary: Option<PathBuf>) -> Pool<Client>

Connections made with Client::connect_exact: the service of this release, started (binary, else the isothrum beside this program, else the one on PATH) when none runs.

Source§

impl<C: Send + Sync + 'static> Pool<C>

Source

pub fn with( connect: impl Fn(PathBuf) -> BoxFuture<'static, Result<C, ClientError>> + Send + Sync + 'static, ) -> Pool<C>

Connections made by connect, given the home.

Source

pub async fn client(&self, home: &Path) -> Result<Arc<C>, ClientError>

home’s connection: the one kept, else a new one, kept.

§Errors

The connection couldn’t be made (no service answers and none could be started).

Source

pub async fn forget(&self, home: &Path)

Forgets home’s connection: the next call makes a new one.

Source

pub async fn retain(&self, keep: impl Fn(&Path) -> bool)

Forgets every connection kept but those of the homes keep keeps.

Source

pub async fn call<T, F>( &self, home: &Path, ask: impl Fn(Arc<C>) -> F, ) -> Result<T, ClientError>
where F: Future<Output = Result<T, ClientError>>,

ask of home’s service. A connection found broken (ClientError::is_broken) is forgotten and made again, and ask tried once more on the new one; a second broken one is forgotten too, for the next call. For a question; an operation is Pool::followed.

§Errors

No connection could be made; the service refused or failed; the connection broke twice.

Source§

impl Pool<Client>

Source

pub async fn follow( &self, home: &Path, command: Command, ) -> Result<Followed, ClientError>

Queues the operation command with home’s service and follows it (Client::follow), on a connection made again once when found broken, as Pool::call does. A sending the connection ended before the service answered (ClientError::Unanswered) may have been queued: it is followed again (Client::follow_again), not sent again, which would queue a second one behind it, or be refused as the run’s operation already queued.

§Errors

As Pool::call and Client::follow.

Trait Implementations§

Source§

impl<C> Debug for Pool<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C = Client> !Freeze for Pool<C>

§

impl<C = Client> !RefUnwindSafe for Pool<C>

§

impl<C = Client> !UnwindSafe for Pool<C>

§

impl<C> Forget for Pool<C>

§

impl<C> Move for Pool<C>

§

impl<C> Send for Pool<C>
where Mutex<HashMap<PathBuf, Arc<C>>>: Send, Box<dyn Fn(PathBuf) -> Pin<Box<dyn Future<Output = Result<C, ClientError>> + Send>> + Send + Sync>: Send,

§

impl<C> Sync for Pool<C>
where Mutex<HashMap<PathBuf, Arc<C>>>: Sync, Box<dyn Fn(PathBuf) -> Pin<Box<dyn Future<Output = Result<C, ClientError>> + Send>> + Send + Sync>: Sync,

§

impl<C> Unpin for Pool<C>
where Mutex<HashMap<PathBuf, Arc<C>>>: Unpin, Box<dyn Fn(PathBuf) -> Pin<Box<dyn Future<Output = Result<C, ClientError>> + Send>> + Send + Sync>: Unpin,

§

impl<C> UnsafeUnpin for Pool<C>
where Mutex<HashMap<PathBuf, Arc<C>>>: UnsafeUnpin, Box<dyn Fn(PathBuf) -> Pin<Box<dyn Future<Output = Result<C, ClientError>> + Send>> + Send + Sync>: UnsafeUnpin,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T> Instrument for T

Source§

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

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

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 T
where 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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