IN - The type that will be received by this clientOUT - The type that will be sent by this clientpublic class NettyTcpClient<IN,OUT> extends TcpClient<IN,OUT>
TcpClient.| Constructor and Description |
|---|
NettyTcpClient(reactor.core.Environment env,
reactor.core.Reactor reactor,
java.net.InetSocketAddress connectAddress,
ClientSocketOptions options,
SslOptions sslOptions,
reactor.io.encoding.Codec<reactor.io.Buffer,IN,OUT> codec,
java.util.Collection<reactor.function.Consumer<NetChannel<IN,OUT>>> consumers)
Creates a new NettyTcpClient that will use the given
env for configuration and the given reactor to
send events. |
| Modifier and Type | Method and Description |
|---|---|
void |
close(reactor.function.Consumer<java.lang.Boolean> onClose)
Close this client and the underlying channel and invoke the given
Consumer when the
operation has completed. |
protected <C> NetChannel<IN,OUT> |
createChannel(C ioChannel)
Subclasses should implement this method and provide a
NetChannel object. |
protected io.netty.channel.ChannelHandler[] |
createChannelHandlers(io.netty.channel.socket.SocketChannel ioChannel) |
reactor.core.composable.Promise<NetChannel<IN,OUT>> |
open()
Open a
NetChannel to the configured host:port and return a Promise that
will be fulfilled when the client is connected. |
reactor.core.composable.Stream<NetChannel<IN,OUT>> |
open(Reconnect reconnect)
Open a
NetChannel to the configured host:port and return a Stream that will be passed a new NetChannel object every time the client is connected to the endpoint. |
getConnectAddress, getOptions, getSslOptionsclose, close, doClose, doCloseChannel, getChannels, getCodec, getConsumers, getEnvironment, getReactor, iterator, notifyClose, notifyError, notifyOpen, notifyShutdown, notifyStart, register, selectpublic NettyTcpClient(@Nonnull
reactor.core.Environment env,
@Nonnull
reactor.core.Reactor reactor,
@Nonnull
java.net.InetSocketAddress connectAddress,
@Nonnull
ClientSocketOptions options,
@Nullable
SslOptions sslOptions,
@Nullable
reactor.io.encoding.Codec<reactor.io.Buffer,IN,OUT> codec,
@Nonnull
java.util.Collection<reactor.function.Consumer<NetChannel<IN,OUT>>> consumers)
env for configuration and the given reactor to
send events. The number of IO threads used by the client is configured by the environment's reactor.tcp.ioThreadCount property. In its absence the number of IO threads will be equal to the number of available processors. The client will connect to the given connectAddress, configuring its socket using the given opts. The given codec will be used for
encoding and decoding of data.env - The configuration environmentreactor - The reactor used to send eventsconnectAddress - The address the client will connect tooptions - The configuration options for the client's socketsslOptions - The SSL configuration options for the client's socketcodec - The codec used to encode and decode dataconsumers - The consumers that will interact with the connectionpublic reactor.core.composable.Promise<NetChannel<IN,OUT>> open()
TcpClientNetChannel to the configured host:port and return a Promise that
will be fulfilled when the client is connected.public reactor.core.composable.Stream<NetChannel<IN,OUT>> open(Reconnect reconnect)
TcpClientNetChannel to the configured host:port and return a Stream that will be passed a new NetChannel object every time the client is connected to the endpoint. The given Reconnect
describes how the client should attempt to reconnect to the host if the initial connection fails or if the client
successfully connects but at some point in the future gets cut off from the host. The Reconnect tells the
client where to try reconnecting and gives a delay describing how long to wait to attempt to reconnect. When the
connect is successfully made, the Stream is sent a new NetChannel backed by the newly-connected
connection.public void close(@Nullable
reactor.function.Consumer<java.lang.Boolean> onClose)
NetClientConsumer when the
operation has completed.protected <C> NetChannel<IN,OUT> createChannel(C ioChannel)
AbstractNetPeerNetChannel object.createChannel in class AbstractNetPeer<IN,OUT>C - The type of the channel object.ioChannel - The IO channel object to associate with this NetChannel.NetChannel object.protected io.netty.channel.ChannelHandler[] createChannelHandlers(io.netty.channel.socket.SocketChannel ioChannel)