Expand description
Often we want the branches of a runtime condition to output different service types. The
Either
Service
allows the reconciliation of two separate types. The Either::Left
and Either::Right
variants can be constructed by
ServiceExt::left
and
ServiceExt::right
respectively.
§Example
use burger::*;
let svc = service_fn(|x| async move { x + 2 });
let svc = if let Some(some) = max_concurrency {
svc.concurrency_limit(some).load_shed().left()
} else {
svc.load_shed().right()
};
let response = svc.oneshot(10u32).await;
§Load
The Load::load
on Either
defers to the variant.