Interface WriteStream<T>
- All Superinterfaces:
MutinyDelegate,StreamBase
- All Known Subinterfaces:
StreamChannel,WebSocketBase
- All Known Implementing Classes:
AmqpSender,AsyncFile,ClientWebSocket,HttpClientRequest,HttpServerResponse,KafkaProducer,NetSocket,QuicStream,ServerWebSocket,SockJSSocket,StreamChannel.StreamChannelImpl,WebSocket,WebSocketBase.WebSocketBaseImpl,WriteStream.WriteStreamImpl
Any class that implements this interface can be used by a Pipe to pipe data from a ReadStream
to it.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
WriteStream
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImpl -
Method Summary
Modifier and TypeMethodDescriptiondrainHandler(Runnable handler) Set a drain handler on the stream.io.smallrye.mutiny.Uni<Void>end()Ends the stream.io.smallrye.mutiny.Uni<Void>Same asend()but writes some data to the stream before ending.exceptionHandler(Consumer<Throwable> handler) Set an exception handler on the write stream.io.vertx.core.streams.WriteStreamstatic <T> WriteStream<T>newInstance(io.vertx.core.streams.WriteStream<T> delegate) Creates a new instance of theWriteStream.static <T> WriteStream<T>newInstance(io.vertx.core.streams.WriteStream<T> delegate, TypeArg<T> typeArg_0) Creates a new instance of theWriteStream.setWriteQueueMaxSize(int maxSize) Set the maximum size of the write queue tomaxSize.io.smallrye.mutiny.Uni<Void>Write some data to the stream.booleanThis will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
Method Details
-
getDelegate
io.vertx.core.streams.WriteStream getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceStreamBase- Returns:
- the delegate used by this Mutiny object of generated type
-
write
Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.streams.WriteStream#write(T)
-
end
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end()
-
end
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.streams.WriteStream#end(T)
-
exceptionHandler
Set an exception handler on the write stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
Set the maximum size of the write queue tomaxSize. You will still be able to write to the stream even if there is more thanmaxSizeitems in the write queue. This is used as an indicator by classes such asPipeto provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket, etc...- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
writeQueueFull
boolean writeQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Returns:
trueif write queue is full
-
drainHandler
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. SeePipefor an example of this being used.The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to
maxSize / 2.- Parameters:
handler- the handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
newInstance
Creates a new instance of theWriteStream. -
newInstance
static <T> WriteStream<T> newInstance(io.vertx.core.streams.WriteStream<T> delegate, TypeArg<T> typeArg_0) Creates a new instance of theWriteStream.
-