use of io.reactivex.netty.protocol.http.server.RequestHandler in project feign by OpenFeign.
the class RealRequestBenchmarks method setup.
@Setup
public void setup() {
server = RxNetty.createHttpServer(SERVER_PORT, new RequestHandler<ByteBuf, ByteBuf>() {
public rx.Observable handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
return response.flush();
}
});
server.start();
client = new OkHttpClient();
client.setRetryOnConnectionFailure(false);
okFeign = Feign.builder().client(new feign.okhttp.OkHttpClient(client)).target(FeignTestInterface.class, "http://localhost:" + SERVER_PORT);
queryRequest = new Request.Builder().url("http://localhost:" + SERVER_PORT + "/?Action=GetUser&Version=2010-05-08&limit=1").build();
}
use of io.reactivex.netty.protocol.http.server.RequestHandler in project Hystrix by Netflix.
the class HystrixMetricsStreamHandlerTest method createServer.
// We try a few times in case we hit into used port.
private HttpServer<ByteBuf, ByteBuf> createServer() {
Random random = new Random();
Exception error = null;
for (int i = 0; i < 3 && server == null; i++) {
port = 10000 + random.nextInt(50000);
try {
return RxNetty.newHttpServerBuilder(port, new HystrixMetricsStreamHandler<ByteBuf, ByteBuf>(DEFAULT_HYSTRIX_PREFIX, DEFAULT_INTERVAL, new // Application handler
RequestHandler<ByteBuf, ByteBuf>() {
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
return Observable.empty();
}
})).build().start();
} catch (Exception e) {
error = e;
}
}
throw new RuntimeException("Cannot initialize RxNetty server", error);
}
Aggregations