public static EventLoopGroup defaultEventloopGroup() { return RxNetty.getRxEventLoopProvider().globalClientEventLoop(true); }
public static Class<? extends Channel> defaultSocketChannelClass() { return RxNetty.isUsingNativeTransport() ? EpollSocketChannel.class : NioSocketChannel.class; }
public static void main(String[] args) { RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() { @Override public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) { throw new NullPointerException("doomsday"); } }).startAndWait(); } }
public static <I, O> RxServer<I, O> createTcpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator, ConnectionHandler<I, O> connectionHandler) { return newTcpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build(); }
public static HttpClient<ByteBuf, ByteBuf> createHttpClient(String host, int port) { return RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port).build(); }
public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, RequestHandler<ByteBuf, ByteBuf> requestHandler) { return newHttpServerBuilder(port, requestHandler).build(); }
public <T extends WebSocketFrame> void connectWebSocketEndpoint(String pathPrefix, ConnectionHandler<T, T> handler) { WebSocketServer<T, T> backend = RxNetty.newWebSocketServerBuilder(0, handler).build(); backend.start(); backendServers.add(backend); proxy.register(ForwardingRule.pathPrefix(backend.getServerPort(), pathPrefix)); logger.info("Started backend WebSocket server on port {} or {}", backend.getServerPort(), handler.getClass().getSimpleName()); }
public static RxClient<ByteBuf, ByteBuf> createTcpClient(String host, int port) { return RxNetty.<ByteBuf, ByteBuf>newTcpClientBuilder(host, port).build(); }
public static <RR, WW> TcpServerState<RR, WW> create(SocketAddress socketAddress) { return create(socketAddress, RxNetty.getRxEventLoopProvider().globalServerEventLoop(true), RxNetty.isUsingNativeTransport() ? EpollServerSocketChannel.class : NioServerSocketChannel.class); }
public static <I, O> UdpServer<I, O> createUdpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator, ConnectionHandler<I, O> connectionHandler) { return newUdpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build(); }
public static void main(String[] args) { RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() { @Override public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) { throw new NullPointerException("doomsday"); } }).startAndWait(); } }
public static <I, O> RxServer<I, O> createTcpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator, ConnectionHandler<I, O> connectionHandler) { return newTcpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build(); }
public static HttpClient<ByteBuf, ByteBuf> createHttpClient(String host, int port) { return RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port).build(); }
public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, RequestHandler<ByteBuf, ByteBuf> requestHandler) { return newHttpServerBuilder(port, requestHandler).build(); }
@PostConstruct public void start() { server = RxNetty.newWebSocketServerBuilder(config.getWebSocketPort(), new ConnectionHandler<WebSocketFrame, WebSocketFrame>() { @Override public Observable<Void> handle(final ObservableConnection<WebSocketFrame, WebSocketFrame> connection) { return connection.getInput().flatMap(new Func1<WebSocketFrame, Observable<Void>>() { @Override public Observable<Void> call(WebSocketFrame wsFrame) { if (wsFrame instanceof TextWebSocketFrame) { TextWebSocketFrame textFrame = (TextWebSocketFrame) wsFrame; logger.info("Got ws-message: " + textFrame.text()); final String cmd = textFrame.text(); if (cmd.equals("get status")) { return streamEurekaStatus(connection); } else { // registry return streamEurekaRegistryData(connection); } } else { return Observable.empty(); } } }); } }).build().start(); logger.info("Starting WebSocket server on port {}...", server.getServerPort()); }
public static RxClient<ByteBuf, ByteBuf> createTcpClient(String host, int port) { return RxNetty.<ByteBuf, ByteBuf>newTcpClientBuilder(host, port).build(); }
public static <I, O> UdpServer<I, O> createUdpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator, ConnectionHandler<I, O> connectionHandler) { return newUdpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build(); }
public void start() { httpServer = RxNetty.createHttpServer(VIEW_PORT, new RequestHandler<ByteBuf, ByteBuf>() { @Override public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) { DeploymentReport report = createReport(); String result; try { result = MAPPER.writeValueAsString(report); } catch (IOException e) { return Observable.error(e); } return response.writeStringAndFlush(result); } }).start(); }
/** * Creates a new {@link KaryonServer} that has a single TCP server instance which delegates all connection * handling to {@link ConnectionHandler}. * The {@link RxServer} is created using {@link RxNetty#newTcpServerBuilder(int, ConnectionHandler)} * * @param port Port for the server. * @param handler Connection Handler * @param bootstrapModules Additional bootstrapModules if any. * * @return {@link KaryonServer} which is to be used to start the created server. */ public static KaryonServer forTcpConnectionHandler(int port, ConnectionHandler<ByteBuf, ByteBuf> handler, BootstrapModule... bootstrapModules) { RxServer<ByteBuf, ByteBuf> server = RxNetty.newTcpServerBuilder(port, handler).build(); return new RxNettyServerBackedServer(server, bootstrapModules); }
public static <I, O> HttpClient<I, O> createHttpClient(String host, int port, PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> configurator) { return RxNetty.<I, O>newHttpClientBuilder(host, port).pipelineConfigurator(configurator).build(); }