ginepro icon indicating copy to clipboard operation
ginepro copied to clipboard

add endpoint middlewares

Open conradludgate opened this issue 2 years ago • 1 comments

Addresses #31. Adds a new EndpointMiddleware trait and adds the with_endpoint_layer method to the LoadBalancedChannelBuilder. These middlewares are invoked on every SocketAddr that the lookup service discovers.

Usage:

let load_balanced_channel = LoadBalancedChannel::builder(("www.test.com", 5000))
        // set the concurrency limit for the endpoint
        .with_endpoint_layer(|endpoint: Endpoint| Some(endpoint.concurrency_limit(1)))
        // set the user agent for the endpoint
        .with_endpoint_layer(|endpoint: Endpoint| {
            endpoint.user_agent("my ginepro client").ok()
        })
        .channel()
        .await
        .unwrap();

conradludgate avatar May 18 '22 10:05 conradludgate