ginepro
ginepro copied to clipboard
add endpoint middlewares
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();