Interface NettyOutbound
- All Known Subinterfaces:
HttpServerResponse,QuicOutbound,UdpOutbound,WebsocketOutbound
- All Known Implementing Classes:
ChannelOperations,HttpOperations,HttpOperations.PostHeadersNettyOutbound
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.
- Author:
- Stephane Maldini
-
Method Summary
Modifier and TypeMethodDescriptionalloc()Returns the assignedByteBufAllocator.default NettyOutboundSends data to the peer, listens for any error on write and closes on terminal signal (complete|error).Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutboundsendByteArray(Publisher<? extends byte[]> dataStream) Sends bytes to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutboundSends content from givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support.default NettyOutboundSends content from the givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support, if the system supports it, the path resolves to a local file systemFile, 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 NettyOutboundsendFileChunked(Path file, long position, long count) Sends content from givenPathusing chunked read/write.default NettyOutboundsendGroups(Publisher<? extends Publisher<? extends ByteBuf>> dataStreams) Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).sendObject(Object message) Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutboundsendObject(Publisher<?> dataStream) Sends an object through Netty pipeline.sendObject(Publisher<?> dataStream, Predicate<Object> predicate) Sends an object through Netty pipeline.default NettyOutboundsendString(Publisher<? extends String> dataStream) Sends String to the peer, listens for any error on write and closes on terminal signal (complete|error).default NettyOutboundsendString(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> NettyOutboundsendUsing(Callable<? extends S> sourceInput, BiFunction<? super Connection, ? super S, ?> mappedInput, Consumer<? super S> sourceCleanup) Binds a send to a starting/cleanup lifecycledefault voidsubscribe(Subscriber<? super Void> s) Subscribes aVoidsubscriber to this outbound and trigger all eventual parent outbound send.then()Obtains aMonoof pending outbound(s) write completion.default NettyOutbounddefault NettyOutboundAppend aPublishertask such as a Mono and return a newNettyOutboundto sequence further send.withConnection(Consumer<? super Connection> withConnection) Call the passed callback with aConnectionto operate on the underlyingChannelstate.
-
Method Details
-
alloc
ByteBufAllocator alloc()Returns the assignedByteBufAllocator.- Returns:
- the
ByteBufAllocator
-
neverComplete
-
send
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutboundtype (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Parameters:
dataStream- the dataStream publishing OUT items to write on this channel- Returns:
- A new
NettyOutboundto append further send. It will emit a complete signal successful sequence write (e.g. after "flush") or any error during write.
-
send
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutboundtype (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Parameters:
dataStream- the dataStream publishing OUT items to write on this channelpredicate- that returns true if explicit flush operation is needed after that buffer- Returns:
- A new
NettyOutboundto append further send. It will emit a complete signal successful sequence write (e.g. after "flush") or any error during write.
-
sendByteArray
Sends bytes to the peer, 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.
- Parameters:
dataStream- the dataStream publishing Buffer items to write on this channel- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFile
Sends content from givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support. If the system supports it and the path resolves to a local file systemFilethen 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
FileRegionin the outboundChannelPipelineNote: Nesting any send* method is not supported.- Parameters:
file- the file Path- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFile
Sends content from the givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support, if the system supports it, the path resolves to a local file systemFile, 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.
- Parameters:
file- the file Pathposition- where to startcount- how much to transfer- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendFileChunked
Sends content from givenPathusing 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.
- Parameters:
file- the file Pathposition- where to startcount- how much to transfer- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendGroups
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error). Each individualPublishercompletion will flush the underlying IO runtime.Note: Nesting any send* method is not supported.
- Parameters:
dataStreams- the dataStream publishing OUT items to write on this channel- Returns:
- A
Monoto signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends an object through Netty pipeline. If type ofPublisher, sends all signals, flushing on complete by default. Write occur in FIFO sequence.Note: Nesting any send* method is not supported.
- Parameters:
dataStream- the dataStream publishing items to write on this channel or a simple pojo supported by configured Netty handlers- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends an object through Netty pipeline. If type ofPublisher, sends all signals, flushing on complete by default. Write occur in FIFO sequence.Note: Nesting any send* method is not supported.
- Parameters:
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 object- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendObject
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).Note: Nesting any send* method is not supported.
- Parameters:
message- the object to publish- Returns:
- A
Monoto signal successful sequence write (e.g. after "flush") or any error during write
-
sendString
Sends String to the peer, 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.
- Parameters:
dataStream- the dataStream publishing Buffer items to write on this channel- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendString
Sends String to the peer, 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.
- Parameters:
dataStream- the dataStream publishing Buffer items to write on this channelcharset- the encoding charset- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
sendUsing
<S> NettyOutbound sendUsing(Callable<? extends S> sourceInput, BiFunction<? super Connection, ? super S, ?> mappedInput, Consumer<? super S> sourceCleanup) Binds a send to a starting/cleanup lifecycleNote: Nesting any send* method is not supported.
- Type Parameters:
S- state type- Parameters:
sourceInput- state generatormappedInput- input to sendsourceCleanup- state cleaner- Returns:
- a new
NettyOutbound
-
subscribe
Subscribes aVoidsubscriber to this outbound and trigger all eventual parent outbound send.- Specified by:
subscribein interfacePublisher<Void>- Parameters:
s- theSubscriberto listen for send sequence completion/failure
-
then
Obtains aMonoof pending outbound(s) write completion.- Returns:
- a
Monoof pending outbound(s) write completion
-
then
- Parameters:
other- thePublisherto subscribe to when this pending outboundthen()is complete;- Returns:
- a new
NettyOutbound
-
then
Append aPublishertask such as a Mono and return a newNettyOutboundto sequence further send.- Parameters:
other- thePublisherto subscribe to when this pending outboundthen()is complete;onCleanup- a cleanup hook when other has terminated or cancelled- Returns:
- a new
NettyOutboundthat
-
withConnection
Call the passed callback with aConnectionto operate on the underlyingChannelstate.- Parameters:
withConnection- connection callback- Returns:
- the
Connection
-