Module burger::steer

source ·
Expand description

Given a collection of services and a Picker, the steer function constructs a Steer Service.

The Service::acquire on Steer acquires all permits from the collection, the Picker then selects which permit and Service to Service::call.

§Example

use burger::*;

async fn main() {
struct AlwaysFirst;

impl<S, Request> steer::Picker<S, Request> for AlwaysFirst {
    fn pick(&self, services: &[S], _request: &Request) -> usize {
        0
    }
}

let svcs = (0..10).map(|index| service_fn(move |x| async move { index * x }));
let picker = AlwaysFirst;
let svc = steer(svcs, picker);
let response = svc.oneshot(7).await;
assert_eq!(0, response);

§Load

This has no Load implementation.

Structs§

Traits§

  • Picks a service from an underlying collection of services to steer requests.

Functions§