Interface ReadStream<T>

All Superinterfaces:
MutinyDelegate, StreamBase
All Known Subinterfaces:
WebSocketBase
All Known Implementing Classes:
AmqpReceiver, AsyncFile, CassandraRowStream, ClientWebSocket, DatagramSocket, HttpClientResponse, HttpServerFileUpload, HttpServerRequest, JsonParser, KafkaConsumer, MessageConsumer, NetSocket, PgChannel, RabbitMQConsumer, RecordParser, RedisConnection, RowStream, ServerWebSocket, SockJSSocket, SQLRowStream, TimeoutStream, WebSocket

public interface ReadStream<T> extends MutinyDelegate, 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 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.
The mode can be changed with the pause(), resume() and fetch(long) methods:
  • Calling resume() sets the flowing mode
  • Calling pause() sets the fetch mode and resets the demand to 0
  • Calling fetch(long) requests a specific amount of elements and adds it to the actual demand

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Method Details

    • getDelegate

      io.vertx.core.streams.ReadStream getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate used by this Mutiny object of generated type
    • toMulti

      @CheckReturnValue io.smallrye.mutiny.Multi<T> toMulti()
    • exceptionHandler

      ReadStream<T> exceptionHandler(Consumer<Throwable> handler)
      Specified by:
      exceptionHandler in interface StreamBase
      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:
    • pipe

      Pipe<T> pipe()
      Returns:
      a pipe
    • pipeTo

      @CheckReturnValue io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<T> dst)
      Pipe this ReadStream to the WriteStream.

      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 of pipeTo(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 of pipeTo(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 from pipeTo(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)