use of io.reactivex.netty.protocol.text.sse.ServerSentEvent in project ribbon by Netflix.
the class NettyClientTest method testStreamWithLoadBalancer.
@Test
public void testStreamWithLoadBalancer() throws Exception {
// NettyHttpLoadBalancerErrorHandler errorHandler = new NettyHttpLoadBalancerErrorHandler(1, 3, true);
// IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "1000");
IClientConfig config = IClientConfig.Builder.newBuilder().withRetryOnAllOperations(true).withMaxAutoRetries(1).withMaxAutoRetriesNextServer(3).build();
BaseLoadBalancer lb = new BaseLoadBalancer(new DummyPing(), new AvailabilityFilteringRule());
LoadBalancingHttpClient<ByteBuf, ServerSentEvent> lbObservables = (LoadBalancingHttpClient<ByteBuf, ServerSentEvent>) RibbonTransport.newSSEClient(lb, config);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/personStream");
List<Person> result = Lists.newArrayList();
Server goodServer = new Server("localhost:" + port);
Server badServer = new Server("localhost:12245");
List<Server> servers = Lists.newArrayList(badServer, badServer, badServer, goodServer);
lb.setServersList(servers);
result = getPersonListFromResponse(lbObservables.submit(request, null, null));
assertEquals(EmbeddedResources.entityStream, result);
}
Aggregations