Search in sources :

Example 1 with LoadBalancingMetric

use of com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetric in project styx by ExpediaGroup.

the class RoundRobinStrategyTest method remoteHostFor.

private static RemoteHost remoteHostFor(String host, int port) {
    Origin origin = newOriginBuilder(host, port).build();
    LoadBalancingMetricSupplier metric = mock(LoadBalancingMetricSupplier.class);
    when(metric.loadBalancingMetric()).thenReturn(new LoadBalancingMetric(45));
    return remoteHost(origin, mock(HttpHandler.class), metric);
}
Also used : Origin(com.hotels.styx.api.extension.Origin) HttpHandler(com.hotels.styx.api.HttpHandler) LoadBalancingMetric(com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetric) LoadBalancingMetricSupplier(com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetricSupplier)

Example 2 with LoadBalancingMetric

use of com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetric in project styx by ExpediaGroup.

the class StyxBackendServiceClientFactoryTest method hostClient.

private StyxHostHttpClient hostClient(LiveHttpResponse response) {
    StyxHostHttpClient mockClient = mock(StyxHostHttpClient.class);
    when(mockClient.sendRequest(any(LiveHttpRequest.class), any(Context.class))).thenReturn(Flux.just(response));
    when(mockClient.loadBalancingMetric()).thenReturn(new LoadBalancingMetric(1));
    return mockClient;
}
Also used : Support.requestContext(com.hotels.styx.support.Support.requestContext) Context(com.hotels.styx.api.HttpInterceptor.Context) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) StyxHostHttpClient(com.hotels.styx.client.StyxHostHttpClient) LoadBalancingMetric(com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetric)

Aggregations

LoadBalancingMetric (com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetric)2 HttpHandler (com.hotels.styx.api.HttpHandler)1 Context (com.hotels.styx.api.HttpInterceptor.Context)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 Origin (com.hotels.styx.api.extension.Origin)1 LoadBalancingMetricSupplier (com.hotels.styx.api.extension.loadbalancing.spi.LoadBalancingMetricSupplier)1 StyxHostHttpClient (com.hotels.styx.client.StyxHostHttpClient)1 Support.requestContext (com.hotels.styx.support.Support.requestContext)1