Interface ReadStream<T>
- All Superinterfaces:
MutinyDelegate,StreamBase
- All Known Subinterfaces:
StreamChannel,WebSocketBase
- All Known Implementing Classes:
AmqpReceiver,AsyncFile,CassandraRowStream,ClientWebSocket,HttpClientResponse,HttpServerFileUpload,HttpServerRequest,JsonParser,KafkaConsumer,MessageConsumer,NetSocket,PgChannel,QuicStream,RabbitMQConsumer,ReadStream.ReadStreamImpl,RecordParser,RedisConnection,RowStream,ServerWebSocket,SockJSSocket,StreamChannel.StreamChannelImpl,WebSocket,WebSocketBase.WebSocketBaseImpl
Any class that implements this interface can be used by a Pipe to pipe data from it
to a WriteStream.
Streaming mode
The stream is either in flowing or fetch mode.-
Initially the stream is in flowing mode.
- When the stream is in flowing mode, elements are delivered to the
handler. - When the stream is in fetch mode, only the number of requested elements will be delivered to the
handler.
pause(), resume() and fetch(long) methods:
- Calling
resume()sets the flowing mode - Calling
pause()sets the fetch mode and resets the demand to0 - Calling
fetch(long)requests a specific amount of elements and adds it to the actual demand
When a hot read stream is obtained (e.g. `HttpServerRequest`), the read stream is in flowing mode, when a cold read stream is obtained (e.g. `AsyncFile`), the read stream is in fetch mode with no demand.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
ReadStream
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImpl -
Method Summary
Modifier and TypeMethodDescriptionendHandler(Runnable endHandler) Set an end handler.exceptionHandler(Consumer<Throwable> handler) Set an exception handler on the read stream.fetch(long amount) Fetch the specifiedamountof elements.io.vertx.core.streams.ReadStreamSet a data handler.static <T> ReadStream<T>newInstance(io.vertx.core.streams.ReadStream<T> delegate) Creates a new instance of theReadStream.static <T> ReadStream<T>newInstance(io.vertx.core.streams.ReadStream<T> delegate, TypeArg<T> typeArg_0) Creates a new instance of theReadStream.pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.pipe()Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream.io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<T> dst) Pipe thisReadStreamto theWriteStream.resume()Resume reading, and sets the buffer inflowingmode.
-
Method Details
-
getDelegate
io.vertx.core.streams.ReadStream getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceStreamBase- Returns:
- the delegate used by this Mutiny object of generated type
-
pipeTo
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
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:
dst- the destination write stream- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.core.streams.ReadStream#pipeTo(WriteStream)
-
exceptionHandler
Set an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
handler
Set a data handler. As data is read, the handler will be called with the data.- Returns:
- a reference to this, so the API can be used fluently
-
pause
ReadStream<T> pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Returns:
- a reference to this, so the API can be used fluently
-
resume
ReadStream<T> resume()Resume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Returns:
- a reference to this, so the API can be used fluently
-
fetch
Fetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Returns:
- a reference to this, so the API can be used fluently
- Throws:
when- the amount is a negative value
-
endHandler
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Returns:
- a reference to this, so the API can be used fluently
-
pipe
Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream. The stream will be resumed when the pipe will be wired to aWriteStream.- Returns:
- a pipe
-
newInstance
Creates a new instance of theReadStream. -
newInstance
static <T> ReadStream<T> newInstance(io.vertx.core.streams.ReadStream<T> delegate, TypeArg<T> typeArg_0) Creates a new instance of theReadStream.
-