Req - Type of requests sent on this connection.Resp - Type of responses read from this connection.public final class DefaultNettyPipelinedConnection<Req,Resp> extends java.lang.Object implements NettyPipelinedConnection<Req,Resp>
NettyPipelinedConnection using a NettyConnection.NettyPipelinedConnection.WriterNettyConnectionContext.FlushStrategyProviderConnectionContext.Protocol| Constructor and Description |
|---|
DefaultNettyPipelinedConnection(NettyConnection<Resp,Req> connection,
int initialQueueSize)
New instance.
|
| Modifier and Type | Method and Description |
|---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. |
FlushStrategy |
defaultFlushStrategy()
Returns the
FlushStrategy used by default for this NettyConnectionContext. |
ExecutionContext |
executionContext()
Get the
ExecutionContext for this ConnectionContext. |
java.net.SocketAddress |
localAddress()
The
SocketAddress to which the associated connection is bound. |
io.netty.channel.Channel |
nettyChannel()
Return the Netty
Channel backing this connection. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
Completable |
onClosing()
Returns a
Completable that notifies when the connection has begun its closing sequence. |
ConnectionContext.Protocol |
protocol()
Get the
ConnectionContext.Protocol for this ConnectionContext. |
java.net.SocketAddress |
remoteAddress()
The
SocketAddress to which the associated connection is connected. |
Publisher<Resp> |
request(NettyPipelinedConnection.Writer writer)
Writes on this connection a request encapsulated in the passed
NettyPipelinedConnection.Writer. |
Publisher<Resp> |
request(NettyPipelinedConnection.Writer writer,
java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
Writes on this connection a request encapsulated in the passed
NettyPipelinedConnection.Writer. |
Publisher<Resp> |
request(Publisher<Req> request)
Send request(s) produced by a
Publisher on this connection. |
Publisher<Resp> |
request(Publisher<Req> request,
java.util.function.Supplier<NettyConnection.RequestNSupplier> requestNSupplierFactory)
Send request(s) produced by a
Publisher on this connection. |
Publisher<Resp> |
request(Publisher<Req> request,
java.util.function.Supplier<NettyConnection.RequestNSupplier> requestNSupplierFactory,
java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
Send request(s) produced by a
Publisher on this connection. |
Publisher<Resp> |
request(Req request)
Writes a
Req object on this connection. |
Publisher<Resp> |
request(Req request,
java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
Writes a
Req object on this connection. |
Publisher<Resp> |
request(Single<Req> request)
Send request produced by a
Single on this connection. |
Publisher<Resp> |
request(Single<Req> request,
java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
Send request produced by a
Single on this connection. |
Publisher<Resp> |
request(java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier,
Publisher<Req> request)
Send request(s) produced by a
Publisher on this connection. |
<T> T |
socketOption(java.net.SocketOption<T> option)
|
javax.net.ssl.SSLSession |
sslSession()
Get the
SSLSession for this connection. |
java.lang.String |
toString() |
Single<java.lang.Throwable> |
transportError()
Returns a
Single<Throwable> that may terminate with an error, if an error is observed at
the transport. |
Cancellable |
updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)
Updates
FlushStrategy associated with this connection. |
public DefaultNettyPipelinedConnection(NettyConnection<Resp,Req> connection, int initialQueueSize)
connection - NettyConnection requests to which are to be pipelined.initialQueueSize - Initial size for the write and read queues.public Publisher<Resp> request(Req request)
NettyPipelinedConnectionReq object on this connection.
Use NettyPipelinedConnection.request(Object, Supplier) to override the predicate used to mark the end of response.
request in interface NettyPipelinedConnection<Req,Resp>request - to write.Publisher for this request.public Publisher<Resp> request(NettyPipelinedConnection.Writer writer)
NettyPipelinedConnectionNettyPipelinedConnection.Writer.
Use NettyPipelinedConnection.request(Writer, Supplier) to override the predicate used to mark the end of response.
request in interface NettyPipelinedConnection<Req,Resp>writer - to write the request.Publisher for this request.public Publisher<Resp> request(NettyPipelinedConnection.Writer writer, java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
NettyPipelinedConnectionNettyPipelinedConnection.Writer.request in interface NettyPipelinedConnection<Req,Resp>writer - to write the request.terminalMsgPredicateSupplier - Supplier of a dynamic Predicate for this request that will
mark the end of the response.Publisher for this request.public Publisher<Resp> request(Req request, java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
NettyPipelinedConnectionReq object on this connection.request in interface NettyPipelinedConnection<Req,Resp>request - to write.terminalMsgPredicateSupplier - Supplier of a dynamic Predicate for this request that will
mark the end of the response.Publisher for this request.public Publisher<Resp> request(Single<Req> request)
NettyPipelinedConnectionSingle on this connection.
Use NettyPipelinedConnection.request(Single, Supplier) to override the predicate used to mark the end of response.
request in interface NettyPipelinedConnection<Req,Resp>request - to write.Publisher for this request.public Publisher<Resp> request(Single<Req> request, java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
NettyPipelinedConnectionSingle on this connection.public Publisher<Resp> request(Publisher<Req> request)
NettyPipelinedConnectionPublisher on this connection.
Use NettyPipelinedConnection.request(Publisher, Supplier) to override the predicate used to mark the end of response.
public Publisher<Resp> request(java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier, Publisher<Req> request)
NettyPipelinedConnectionPublisher on this connection.request in interface NettyPipelinedConnection<Req,Resp>terminalMsgPredicateSupplier - Supplier of a dynamic Predicate for this request that will
mark the end of the response.request - Publisher producing the request(s) to write.Publisher for this request.public Publisher<Resp> request(Publisher<Req> request, java.util.function.Supplier<NettyConnection.RequestNSupplier> requestNSupplierFactory)
NettyPipelinedConnectionPublisher on this connection.
Use NettyPipelinedConnection.request(Publisher, Supplier, Supplier) to override the predicate used to mark the end of
response.
request in interface NettyPipelinedConnection<Req,Resp>request - Publisher producing the request(s) to write.requestNSupplierFactory - A Supplier of NettyConnection.RequestNSupplier for this request.Publisher for this request.public Publisher<Resp> request(Publisher<Req> request, java.util.function.Supplier<NettyConnection.RequestNSupplier> requestNSupplierFactory, java.util.function.Supplier<java.util.function.Predicate<Resp>> terminalMsgPredicateSupplier)
NettyPipelinedConnectionPublisher on this connection.request in interface NettyPipelinedConnection<Req,Resp>request - Publisher producing the request(s) to write.requestNSupplierFactory - A Supplier of NettyConnection.RequestNSupplier for this request.terminalMsgPredicateSupplier - Supplier of a dynamic Predicate for this request that will
mark the end of the response.Publisher for this request.public java.net.SocketAddress localAddress()
ConnectionContextSocketAddress to which the associated connection is bound.localAddress in interface ConnectionContextSocketAddress to which the associated connection is bound.public java.net.SocketAddress remoteAddress()
ConnectionContextSocketAddress to which the associated connection is connected.remoteAddress in interface ConnectionContextSocketAddress to which the associated connection is connected.@Nullable public javax.net.ssl.SSLSession sslSession()
ConnectionContextSSLSession for this connection.sslSession in interface ConnectionContextSSLSession if SSL/TLS is enabled, or null otherwise.public ExecutionContext executionContext()
ConnectionContextExecutionContext for this ConnectionContext.
The ExecutionContext.ioExecutor() will represent the thread responsible for IO for this
ConnectionContext. Note that this maybe different that what was used to create this object because
at this time a specific IoExecutor has been selected.
executionContext in interface ConnectionContextExecutionContext for this ConnectionContext.@Nullable public <T> T socketOption(java.net.SocketOption<T> option)
ConnectionContextsocketOption in interface ConnectionContextT - the type of the SocketOption value.option - SocketOption to get.SocketOption value of type T for this ConnectionContext or null if
this SocketOption is not supported by this ConnectionContext.StandardSocketOptions,
ServiceTalkSocketOptionspublic ConnectionContext.Protocol protocol()
ConnectionContextConnectionContext.Protocol for this ConnectionContext.protocol in interface ConnectionContextConnectionContext.Protocol for this ConnectionContext.public Single<java.lang.Throwable> transportError()
NettyConnectionContextSingle<Throwable> that may terminate with an error, if an error is observed at
the transport.transportError in interface NettyConnectionContextSingle<Throwable> that may terminate with an error, if an error is observed at
the transport.public Completable onClosing()
NettyConnectionContextCompletable that notifies when the connection has begun its closing sequence.onClosing in interface NettyConnectionContextCompletable that notifies when the connection has begun its closing sequence. A configured
CloseHandler will determine whether more reads or writes will be allowed on this
NettyConnectionContext.public Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync().
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync().
closeAsyncGracefully in interface AsyncCloseableCompletable that is notified once the close is complete.public io.netty.channel.Channel nettyChannel()
NettyConnectionContextChannel backing this connection.nettyChannel in interface NettyConnectionContextChannel backing this connection.public java.lang.String toString()
toString in class java.lang.Objectpublic Cancellable updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)
NettyConnectionContextFlushStrategy associated with this connection. Updated FlushStrategy will be used in any
subsequent writes on this connection.updateFlushStrategy in interface NettyConnectionContextstrategyProvider - NettyConnectionContext.FlushStrategyProvider to provide a new FlushStrategy.
NettyConnectionContext.FlushStrategyProvider.computeFlushStrategy(FlushStrategy, boolean) MAY be invoked
multiple times for a single call to this method and is expected to be idempotent.Cancellable that will cancel this update.public FlushStrategy defaultFlushStrategy()
NettyConnectionContextFlushStrategy used by default for this NettyConnectionContext.defaultFlushStrategy in interface NettyConnectionContextFlushStrategy used by default for this NettyConnectionContext.