@Override public Mono<CloseableChannel> start(ConnectionAcceptor acceptor) { Objects.requireNonNull(acceptor, "acceptor must not be null"); return server .doOnConnection( c -> { c.addHandlerLast(new RSocketLengthCodec()); TcpDuplexConnection connection = new TcpDuplexConnection(c); acceptor.apply(connection).then(Mono.<Void>never()).subscribe(c.disposeSubscriber()); }) .bind() .map(CloseableChannel::new); } }
@Override public Mono<? extends DisposableServer> bind(ServerBootstrap b) { return source.bind(b); }
@Override public Mono<? extends DisposableServer> bind(ServerBootstrap b) { return source.bind(b); }
@Override @SuppressWarnings("unchecked") public Mono<? extends DisposableServer> bind(TcpServer delegate) { return delegate.bootstrap(this) .bind() .map(CLEANUP_GLOBAL_RESOURCE); }
/** * Start a Server in a blocking fashion, and wait for it to finish initializing. The * returned {@link DisposableServer} offers simple server API, including to {@link * DisposableServer#disposeNow()} shut it down in a blocking fashion. * * @param timeout max startup timeout * * @return a {@link DisposableServer} */ public final DisposableServer bindNow(Duration timeout) { Objects.requireNonNull(timeout, "timeout"); try { return Objects.requireNonNull(bind().block(timeout), "aborted"); } catch (IllegalStateException e) { if (e.getMessage().contains("blocking read")) { throw new IllegalStateException("HttpServer couldn't be started within " + timeout.toMillis() + "ms"); } throw e; } }
@Override @SuppressWarnings("unchecked") public Mono<? extends DisposableServer> bind(TcpServer delegate) { return delegate.bootstrap(this) .bind() .map(CLEANUP_GLOBAL_RESOURCE); }
/** * Start a Server in a blocking fashion, and wait for it to finish initializing. The * returned {@link DisposableServer} offers simple server API, including to {@link * DisposableServer#disposeNow()} shut it down in a blocking fashion. * * @param timeout max startup timeout * * @return a {@link DisposableServer} */ public final DisposableServer bindNow(Duration timeout) { Objects.requireNonNull(timeout, "timeout"); try { return Objects.requireNonNull(bind().block(timeout), "aborted"); } catch (IllegalStateException e) { if (e.getMessage().contains("blocking read")) { throw new IllegalStateException("HttpServer couldn't be started within " + timeout.toMillis() + "ms"); } throw e; } }
/** * Starts to accept connections on local address. * * @return mono transport */ public Mono<Transport> bind0() { return newTcpServer() .handle(this::onMessage) .bind() .doOnSuccess( server -> LOGGER.debug("Bound cluster transport on {}:{}", server.host(), server.port())) .doOnError( ex -> LOGGER.error( "Failed to bind cluster transport on port={}, cause: {}", config.getPort(), ex.toString())) .map(this::onBind); }
/** * Bind the {@link TcpServer} and return a {@link Mono} of {@link DisposableServer}. If * {@link Mono} is cancelled, the underlying binding will be aborted. Once the {@link * DisposableServer} has been emitted and is not necessary anymore, disposing main server * loop must be done by the user via {@link DisposableServer#dispose()}. * * If updateConfiguration phase fails, a {@link Mono#error(Throwable)} will be returned; * * @return a {@link Mono} of {@link DisposableServer} */ public final Mono<? extends DisposableServer> bind() { ServerBootstrap b; try{ b = configure(); } catch (Throwable t){ Exceptions.throwIfFatal(t); return Mono.error(t); } return bind(b); }
/** * Bind the {@link TcpServer} and return a {@link Mono} of {@link DisposableServer}. If * {@link Mono} is cancelled, the underlying binding will be aborted. Once the {@link * DisposableServer} has been emitted and is not necessary anymore, disposing main server * loop must be done by the user via {@link DisposableServer#dispose()}. * * If updateConfiguration phase fails, a {@link Mono#error(Throwable)} will be returned; * * @return a {@link Mono} of {@link DisposableServer} */ public final Mono<? extends DisposableServer> bind() { ServerBootstrap b; try{ b = configure(); } catch (Throwable t){ Exceptions.throwIfFatal(t); return Mono.error(t); } return bind(b); }
@Override public Mono<CloseableChannel> start(ConnectionAcceptor acceptor) { Objects.requireNonNull(acceptor, "acceptor must not be null"); return server .doOnConnection( c -> { c.addHandlerLast(new RSocketLengthCodec()); TcpDuplexConnection connection = new TcpDuplexConnection(c); acceptor.apply(connection).then(Mono.<Void>never()).subscribe(c.disposeSubscriber()); }) .bind() .map(CloseableChannel::new); } }