Interface ReadStream<T>
-
- All Superinterfaces:
StreamBase
- All Known Subinterfaces:
WebSocketBase
- All Known Implementing Classes:
AmqpReceiver
,AsyncFile
,CassandraRowStream
,ClientWebSocket
,DatagramSocket
,GrpcClientResponse
,GrpcReadStream
,GrpcServerRequest
,HttpClientResponse
,HttpServerFileUpload
,HttpServerRequest
,JsonParser
,KafkaConsumer
,MessageConsumer
,NetSocket
,PgChannel
,RabbitMQConsumer
,RecordParser
,RedisConnection
,RowStream
,ServerWebSocket
,SockJSSocket
,SQLRowStream
,TestSuiteReport
,TimeoutStream
,WebSocket
public interface ReadStream<T> extends StreamBase
Represents a stream of items that can be read from.Any class that implements this interface can be used by a
Pipe
to pipe data from it to aWriteStream
.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()
andfetch(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
original
non RX-ified interface using Vert.x codegen.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ReadStream<T>
endHandler(Handler<Void> endHandler)
Set an end handler.ReadStream<T>
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.ReadStream<T>
fetch(long amount)
Fetch the specifiedamount
of elements.ReadStream
getDelegate()
ReadStream<T>
handler(Handler<T> handler)
Set a data handler.static <T> ReadStream<T>
newInstance(ReadStream arg)
static <T> ReadStream<T>
newInstance(ReadStream arg, TypeArg<T> __typeArg_T)
ReadStream<T>
pause()
Pause theReadStream
, it sets the buffer infetch
mode and clears the actual demand.Pipe<T>
pipe()
Pause this stream and return aPipe
to transfer the elements of this stream to a destinationWriteStream
.void
pipeTo(WriteStream<T> dst)
Pipe thisReadStream
to theWriteStream
.void
pipeTo(WriteStream<T> dst, Handler<AsyncResult<Void>> handler)
Pipe thisReadStream
to theWriteStream
.ReadStream<T>
resume()
Resume reading, and sets the buffer inflowing
mode.io.reactivex.Completable
rxPipeTo(WriteStream<T> dst)
Pipe thisReadStream
to theWriteStream
.io.reactivex.Flowable<T>
toFlowable()
io.reactivex.Observable<T>
toObservable()
-
-
-
Method Detail
-
getDelegate
ReadStream getDelegate()
- Specified by:
getDelegate
in interfaceStreamBase
-
exceptionHandler
ReadStream<T> exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.- Specified by:
exceptionHandler
in interfaceStreamBase
- Parameters:
handler
- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
ReadStream<T> handler(Handler<T> handler)
Set a data handler. As data is read, the handler will be called with the data.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
pause
ReadStream<T> pause()
Pause theReadStream
, it sets the buffer infetch
mode 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 inflowing
mode. If theReadStream
has been paused, reading will recommence on it.- Returns:
- a reference to this, so the API can be used fluently
-
fetch
ReadStream<T> fetch(long amount)
Fetch the specifiedamount
of elements. If theReadStream
has been paused, reading will recommence with the specifiedamount
of items, otherwise the specifiedamount
will be added to the current stream demand.- Parameters:
amount
-- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
ReadStream<T> endHandler(Handler<Void> endHandler)
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Parameters:
endHandler
-- Returns:
- a reference to this, so the API can be used fluently
-
pipe
Pipe<T> pipe()
Pause this stream and return aPipe
to 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
-
pipeTo
void pipeTo(WriteStream<T> dst, Handler<AsyncResult<Void>> handler)
Pipe thisReadStream
to theWriteStream
.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handler
will be called with the result.- Parameters:
dst
- the destination write streamhandler
-
-
pipeTo
void pipeTo(WriteStream<T> dst)
Pipe thisReadStream
to theWriteStream
.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handler
will be called with the result.- Parameters:
dst
- the destination write stream
-
rxPipeTo
io.reactivex.Completable rxPipeTo(WriteStream<T> dst)
Pipe thisReadStream
to theWriteStream
.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handler
will be called with the result.- Parameters:
dst
- the destination write stream- Returns:
-
toObservable
io.reactivex.Observable<T> toObservable()
-
toFlowable
io.reactivex.Flowable<T> toFlowable()
-
newInstance
static <T> ReadStream<T> newInstance(ReadStream arg)
-
newInstance
static <T> ReadStream<T> newInstance(ReadStream arg, TypeArg<T> __typeArg_T)
-
-