Class WriteStream.WriteStreamImpl<T>
- All Implemented Interfaces:
MutinyDelegate,StreamBase,WriteStream<T>
- Enclosing interface:
- WriteStream<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImplNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.WriteStream
WriteStream.WriteStreamImpl<T> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWriteStreamImpl(io.vertx.core.streams.WriteStream<T> delegate) Create a new instance ofWriteStream.WriteStreamImpldelegating to the given (non-null) instance ofWriteStream.WriteStreamImpl(io.vertx.core.streams.WriteStream<T> delegate, TypeArg<T> typeArg_0) -
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.voidEnds the stream.voidendAndAwait(T data) Same asend()but writes some data to the stream before ending.Ends the stream.endAndForget(T data) 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.WriteStream<T>Get the delegate instance.setWriteQueueMaxSize(int maxSize) Set the maximum size of the write queue tomaxSize.io.smallrye.mutiny.Uni<Void>Write some data to the stream.voidwriteAndAwait(T data) Write some data to the stream.writeAndForget(T data) Write some data to the stream.booleanThis will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
Field Details
-
__typeArg_0
-
-
Constructor Details
-
WriteStreamImpl
Create a new instance ofWriteStream.WriteStreamImpldelegating to the given (non-null) instance ofWriteStream. -
WriteStreamImpl
-
-
Method Details
-
getDelegate
Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<T>- Returns:
- the delegate instance
-
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.
- Specified by:
writein interfaceWriteStream<T>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.streams.WriteStream#write(T)
-
writeAndAwait
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 underlying 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
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
io.vertx.core.streams.WriteStream#write(T)
-
writeAndForget
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 underlying 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 ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- 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.
- Specified by:
endin interfaceWriteStream<T>- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end()
-
endAndAwait
public void endAndAwait()Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
WriteStream.end()
-
endAndForget
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- 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.
- Specified by:
endin interfaceWriteStream<T>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.streams.WriteStream#end(T)
-
endAndAwait
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
io.vertx.core.streams.WriteStream#end(T)
-
endAndForget
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
io.vertx.core.streams.WriteStream#end(T)
-
exceptionHandler
Set an exception handler on the write stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<T>- 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...- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<T>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
writeQueueFull
public boolean writeQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Specified by:
writeQueueFullin interfaceWriteStream<T>- 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.- Specified by:
drainHandlerin interfaceWriteStream<T>- Parameters:
handler- the handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-