Rust

pool

Module

Sharing a bounded set of clients between concurrent callers.

Contents

use utopia_client::Pool;
Rust
pub struct Pool<A, S>

A client that borrows a pooled adapter for the duration of each request and returns it once the request completes, so concurrent callers share a bounded set of connections. An adapter whose request failed is discarded (its connection may be broken) and replaced on demand.

Rust
use utopia_client::{Http, Pool, Request};
use utopia_pools::{Channel, Pool as Connections};

let connections = Connections::new(Channel::new(), "api", 8, || async {
    Ok::<_, utopia_client::Error>(Http::new())
}, 5.0).map_err(utopia_client::Error::from)?;
let pool = Pool::new(connections);
let response = pool.send(Request::new("GET", "https://example.com/")?).await?;
Compiles in CI; needs a running service to execute.