group
Module[Group]: pools by name.
Contents
use utopia_pools::Group;Rust
pub struct Group<T, A>Pools by name, to reclaim them together or run work with a connection from several at once.
The pools of one group lend one resource type; pools of different resources share a group through an enum resource.
Rust
use utopia_pools::{Group, Pool, Stack};
let make = |name: &str, value: &'static str| {
Pool::new(Stack::new(), name, 1, move || async move { Ok::<_, std::io::Error>(value) }, 0.0)
};
let mut group = Group::new();
group.add(make("db", "1")?).add(make("cache", "3")?);
let joined = group.with(&["db", "cache"], async |resources| Ok::<_, utopia_pools::Error>(resources.iter().map(|r| **r).collect::<String>())).await?;
assert_eq!(joined, "13");Also implements
Default.