Function spirit_tokio::utils::resources
source · pub fn resources<Config, Consumer, E, R, O, C, N>(
extract: E,
consumer: Consumer,
name: N
) -> impl Helper<O, C>where
Config: ResourceConfig<O, C>,
Consumer: ResourceConsumer<Config, O, C>,
C: DeserializeOwned + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
E: FnMut(&C) -> R + Send + 'static,
R: IntoIterator<Item = Config>,
N: Name,
Expand description
Binds a ResourceConfig
and ResourceConsumer
together to form a Helper
.
This takes an extractor function returning an iterator of ResourceConfig
s from the
configuration. Then it binds it together with the provided ResourceConsumer
and takes care
of reconfiguring the resources, spawning the appropriate number of them, etc.
If the configuration always contains exactly one instance, use resource
.
Oftentimes, the configuration fragments also implement IteratedCfgHelper
, so it can be used
with config_helper
too.