Interface ReadStream<T>
-
- All Superinterfaces:
StreamBase
- All Known Subinterfaces:
WebSocketBase
- All Known Implementing Classes:
AmqpReceiver
,AsyncFile
,CassandraRowStream
,DatagramSocket
,HttpClientResponse
,HttpServerFileUpload
,HttpServerRequest
,JsonParser
,KafkaConsumer
,MessageConsumer
,NetSocket
,PgChannel
,RabbitMQConsumer
,RecordParser
,RedisConnection
,RowStream
,ServerWebSocket
,SockJSSocket
,SQLRowStream
,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 Mutiny-ified interface using Vert.x codegen.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ReadStream<T>
endHandler(Runnable endHandler)
ReadStream<T>
exceptionHandler(Consumer<Throwable> handler)
ReadStream<T>
fetch(long amount)
io.vertx.core.streams.ReadStream
getDelegate()
ReadStream<T>
handler(Consumer<T> handler)
static <T> ReadStream<T>
newInstance(io.vertx.core.streams.ReadStream arg)
static <T> ReadStream<T>
newInstance(io.vertx.core.streams.ReadStream arg, TypeArg<T> __typeArg_T)
ReadStream<T>
pause()
Pipe<T>
pipe()
io.smallrye.mutiny.Uni<Void>
pipeTo(WriteStream<T> dst)
Pipe thisReadStream
to theWriteStream
.Void
pipeToAndAwait(WriteStream<T> dst)
Blocking variant ofpipeTo(io.vertx.mutiny.core.streams.WriteStream)
.void
pipeToAndForget(WriteStream<T> dst)
Variant ofpipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.ReadStream<T>
resume()
io.smallrye.mutiny.Multi<T>
toMulti()
-
-
-
Method Detail
-
getDelegate
io.vertx.core.streams.ReadStream getDelegate()
- Specified by:
getDelegate
in interfaceStreamBase
-
toMulti
@CheckReturnValue io.smallrye.mutiny.Multi<T> toMulti()
-
exceptionHandler
ReadStream<T> exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandler
in interfaceStreamBase
- Parameters:
handler
- the exception handler- Returns:
-
handler
ReadStream<T> handler(Consumer<T> handler)
- Parameters:
handler
-- Returns:
-
pause
ReadStream<T> pause()
- Returns:
- a reference to this, so the API can be used fluently
-
resume
ReadStream<T> resume()
- Returns:
- a reference to this, so the API can be used fluently
-
fetch
ReadStream<T> fetch(long amount)
- Parameters:
amount
-- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
ReadStream<T> endHandler(Runnable endHandler)
- Parameters:
endHandler
-- Returns:
-
pipeTo
@CheckReturnValue io.smallrye.mutiny.Uni<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.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
dst
- the destination write stream- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
Void pipeToAndAwait(WriteStream<T> dst)
Blocking variant ofpipeTo(io.vertx.mutiny.core.streams.WriteStream)
.This method waits 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 a RuntimeException).
- Parameters:
dst
- the destination write stream- Returns:
- the Void instance produced by the operation.
-
pipeToAndForget
void pipeToAndForget(WriteStream<T> dst)
Variant ofpipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.This method subscribes on the result of
pipeTo(io.vertx.mutiny.core.streams.WriteStream)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompipeTo(io.vertx.mutiny.core.streams.WriteStream)
but you don't need to compose it with other operations.- Parameters:
dst
- the destination write stream
-
newInstance
static <T> ReadStream<T> newInstance(io.vertx.core.streams.ReadStream arg)
-
newInstance
static <T> ReadStream<T> newInstance(io.vertx.core.streams.ReadStream arg, TypeArg<T> __typeArg_T)
-
-