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<C: Send + Sync + 'static> Pool<C>
impl<C: Send + Sync + 'static> Pool<C>
Sourcepub fn with(
connect: impl Fn(PathBuf) -> BoxFuture<'static, Result<C, ClientError>> + Send + Sync + 'static,
) -> Pool<C>
pub fn with( connect: impl Fn(PathBuf) -> BoxFuture<'static, Result<C, ClientError>> + Send + Sync + 'static, ) -> Pool<C>
Connections made by connect, given the home.
Sourcepub async fn client(&self, home: &Path) -> Result<Arc<C>, ClientError>
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).
Sourcepub async fn forget(&self, home: &Path)
pub async fn forget(&self, home: &Path)
Forgets home’s connection: the next call makes a new one.
Sourcepub async fn retain(&self, keep: impl Fn(&Path) -> bool)
pub async fn retain(&self, keep: impl Fn(&Path) -> bool)
Forgets every connection kept but those of the homes keep keeps.
Sourcepub async fn call<T, F>(
&self,
home: &Path,
ask: impl Fn(Arc<C>) -> F,
) -> Result<T, ClientError>
pub async fn call<T, F>( &self, home: &Path, ask: impl Fn(Arc<C>) -> F, ) -> 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>
impl Pool<Client>
Sourcepub async fn follow(
&self,
home: &Path,
command: Command,
) -> Result<Followed, ClientError>
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.