Class Pump


  • public class Pump
    extends Object
    Pumps data from a ReadStream to a WriteStream and performs flow control where necessary to prevent the write stream buffer from getting overfull.

    Instances of this class read items from a ReadStream and write them to a WriteStream. If data can be read faster than it can be written this could result in the write queue of the WriteStream growing without bound, eventually causing it to exhaust all available RAM.

    To prevent this, after each write, instances of this class check whether the write queue of the WriteStream is full, and if so, the ReadStream is paused, and a drainHandler is set on the WriteStream.

    When the WriteStream has processed half of its backlog, the drainHandler will be called, which results in the pump resuming the ReadStream.

    This class can be used to pump from any ReadStream to any WriteStream, e.g. from an HttpServerRequest to an AsyncFile, or from NetSocket to a WebSocket.

    Please see the documentation for more information.

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

    • Field Detail

      • __TYPE_ARG

        public static final TypeArg<Pump> __TYPE_ARG
    • Constructor Detail

      • Pump

        public Pump​(io.vertx.core.streams.Pump delegate)
      • Pump

        public Pump​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.core.streams.Pump getDelegate()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • pump

        public static <T> Pump pump​(ReadStream<T> rs,
                                    WriteStream<T> ws)
        Parameters:
        rs - the read stream
        ws - the write stream
        Returns:
        the pump
      • pump

        public static <T> Pump pump​(org.reactivestreams.Publisher<T> rs,
                                    WriteStream<T> ws)
        Parameters:
        rs - the read stream
        ws - the write stream
        Returns:
        the pump
      • pump

        public static <T> Pump pump​(ReadStream<T> rs,
                                    WriteStream<T> ws,
                                    int writeQueueMaxSize)
        Parameters:
        rs - the read stream
        ws - the write stream
        writeQueueMaxSize - the max size of the write queue
        Returns:
        the pump
      • pump

        public static <T> Pump pump​(org.reactivestreams.Publisher<T> rs,
                                    WriteStream<T> ws,
                                    int writeQueueMaxSize)
        Parameters:
        rs - the read stream
        ws - the write stream
        writeQueueMaxSize - the max size of the write queue
        Returns:
        the pump
      • setWriteQueueMaxSize

        public Pump setWriteQueueMaxSize​(int maxSize)
        Parameters:
        maxSize - the max size
        Returns:
        a reference to this, so the API can be used fluently
      • start

        public Pump start()
        Returns:
        a reference to this, so the API can be used fluently
      • stop

        public Pump stop()
        Returns:
        a reference to this, so the API can be used fluently
      • numberPumped

        public int numberPumped()
        Returns:
      • newInstance

        public static Pump newInstance​(io.vertx.core.streams.Pump arg)