public interface NettyOutbound extends Publisher<Void>
Channel
.
Note: With HTTP, chaining multiple send operations is discouraged and will not work as expected
when send involves scalar or mono publishers. For instance send(flux).send(mono)
or send(flux).sendObject(message)
will ignore send(flux)
.
This is an anticipation of an API simplification moving forward next versions where
send will not return NettyOutbound
anymore.
Modifier and Type | Method and Description |
---|---|
ByteBufAllocator |
alloc()
Returns the assigned
ByteBufAllocator . |
default Mono<Void> |
neverComplete()
|
default NettyOutbound |
send(Publisher<? extends ByteBuf> dataStream)
Sends data to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
NettyOutbound |
send(Publisher<? extends ByteBuf> dataStream,
java.util.function.Predicate<ByteBuf> predicate)
Sends data to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
default NettyOutbound |
sendByteArray(Publisher<? extends byte[]> dataStream)
Sends bytes to the peer, listens for any error on write and closes on terminal
signal (complete|error).
|
default NettyOutbound |
sendFile(Path file)
Sends content from given
Path using
FileChannel.transferTo(long, long, WritableByteChannel)
support. |
default NettyOutbound |
sendFile(Path file,
long position,
long count)
Sends content from the given
Path using
FileChannel.transferTo(long, long, WritableByteChannel)
support, if the system supports it, the path resolves to a local file
system File , compression and SSL/TLS is not enabled, then transfer will
use zero-byte copy to the peer., otherwise chunked read/write will be used. |
default NettyOutbound |
sendFileChunked(Path file,
long position,
long count)
Sends content from given
Path using chunked read/write. |
default NettyOutbound |
sendGroups(Publisher<? extends Publisher<? extends ByteBuf>> dataStreams)
Sends data to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
NettyOutbound |
sendObject(Object message)
Sends data to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
default NettyOutbound |
sendObject(Publisher<?> dataStream)
Sends an object through Netty pipeline.
|
NettyOutbound |
sendObject(Publisher<?> dataStream,
java.util.function.Predicate<Object> predicate)
Sends an object through Netty pipeline.
|
default NettyOutbound |
sendString(Publisher<? extends String> dataStream)
Sends String to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
default NettyOutbound |
sendString(Publisher<? extends String> dataStream,
Charset charset)
Sends String to the peer, listens for any error on write and closes on terminal signal
(complete|error).
|
<S> NettyOutbound |
sendUsing(Callable<? extends S> sourceInput,
java.util.function.BiFunction<? super Connection,? super S,?> mappedInput,
java.util.function.Consumer<? super S> sourceCleanup)
Binds a send to a starting/cleanup lifecycle
|
default void |
subscribe(Subscriber<? super Void> s)
Subscribes a
Void subscriber to this outbound and trigger all eventual
parent outbound send. |
default Mono<Void> |
then()
Obtains a
Mono of pending outbound(s) write completion. |
default NettyOutbound |
then(Publisher<Void> other)
|
default NettyOutbound |
then(Publisher<Void> other,
Runnable onCleanup)
Append a
Publisher task such as a Mono and return a new
NettyOutbound to sequence further send. |
NettyOutbound |
withConnection(java.util.function.Consumer<? super Connection> withConnection)
Call the passed callback with a
Connection to operate on the underlying
Channel state. |
ByteBufAllocator alloc()
ByteBufAllocator
.ByteBufAllocator
default NettyOutbound send(Publisher<? extends ByteBuf> dataStream)
A new NettyOutbound
type (or the same) for typed send
sequences.
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing OUT items to write on this channelNettyOutbound
to append further send. It will emit a complete
signal successful sequence write (e.g. after "flush") or any error during write.NettyOutbound send(Publisher<? extends ByteBuf> dataStream, java.util.function.Predicate<ByteBuf> predicate)
A new NettyOutbound
type (or the same) for typed send
sequences.
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing OUT items to write on this channelpredicate
- that returns true if explicit flush operation is needed after that bufferNettyOutbound
to append further send. It will emit a complete
signal successful sequence write (e.g. after "flush") or any error during write.default NettyOutbound sendByteArray(Publisher<? extends byte[]> dataStream)
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing Buffer items to write on this channeldefault NettyOutbound sendFile(Path file)
Path
using
FileChannel.transferTo(long, long, WritableByteChannel)
support. If the system supports it and the path resolves to a local file
system File
then transfer will use zero-byte copy
to the peer.
It will listen for any error on write and close on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: this will emit FileRegion
in the outbound
ChannelPipeline
Note: Nesting any send* method is not supported.
file
- the file Pathdefault NettyOutbound sendFile(Path file, long position, long count)
Path
using
FileChannel.transferTo(long, long, WritableByteChannel)
support, if the system supports it, the path resolves to a local file
system File
, compression and SSL/TLS is not enabled, then transfer will
use zero-byte copy to the peer., otherwise chunked read/write will be used.
It will listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: Nesting any send* method is not supported.file
- the file Pathposition
- where to startcount
- how much to transferdefault NettyOutbound sendFileChunked(Path file, long position, long count)
Path
using chunked read/write. It will listen for any error on write and close on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: Nesting any send* method is not supported.
file
- the file Pathposition
- where to startcount
- how much to transferdefault NettyOutbound sendGroups(Publisher<? extends Publisher<? extends ByteBuf>> dataStreams)
Publisher
completion will flush
the underlying IO runtime.
Note: Nesting any send* method is not supported.
dataStreams
- the dataStream publishing OUT items to write on this channelMono
to signal successful sequence write (e.g. after "flush") or
any error during writedefault NettyOutbound sendObject(Publisher<?> dataStream)
Publisher
, sends all signals,
flushing on complete by default. Write occur in FIFO sequence.
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing items to write on this channel
or a simple pojo supported by configured Netty handlersNettyOutbound sendObject(Publisher<?> dataStream, java.util.function.Predicate<Object> predicate)
Publisher
, sends all signals,
flushing on complete by default. Write occur in FIFO sequence.
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing items to write on this channel
or a simple pojo supported by configured Netty handlerspredicate
- that returns true if explicit flush operation is needed after that objectNettyOutbound sendObject(Object message)
Note: Nesting any send* method is not supported.
message
- the object to publishMono
to signal successful sequence write (e.g. after "flush") or
any error during writedefault NettyOutbound sendString(Publisher<? extends String> dataStream)
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing Buffer items to write on this channeldefault NettyOutbound sendString(Publisher<? extends String> dataStream, Charset charset)
Note: Nesting any send* method is not supported.
dataStream
- the dataStream publishing Buffer items to write on this channelcharset
- the encoding charset<S> NettyOutbound sendUsing(Callable<? extends S> sourceInput, java.util.function.BiFunction<? super Connection,? super S,?> mappedInput, java.util.function.Consumer<? super S> sourceCleanup)
Note: Nesting any send* method is not supported.
S
- state typesourceInput
- state generatormappedInput
- input to sendsourceCleanup
- state cleanerNettyOutbound
default void subscribe(Subscriber<? super Void> s)
Void
subscriber to this outbound and trigger all eventual
parent outbound send.subscribe
in interface Publisher<Void>
s
- the Subscriber
to listen for send sequence completion/failuredefault Mono<Void> then()
Mono
of pending outbound(s) write completion.Mono
of pending outbound(s) write completiondefault NettyOutbound then(Publisher<Void> other)
other
- the Publisher
to subscribe to when this pending outbound
then()
is complete;NettyOutbound
default NettyOutbound then(Publisher<Void> other, Runnable onCleanup)
Publisher
task such as a Mono and return a new
NettyOutbound
to sequence further send.other
- the Publisher
to subscribe to when this pending outbound
then()
is complete;onCleanup
- a cleanup hook when other has terminated or cancelledNettyOutbound
thatNettyOutbound withConnection(java.util.function.Consumer<? super Connection> withConnection)
Connection
to operate on the underlying
Channel
state.withConnection
- connection callbackConnection