Class Pump
- java.lang.Object
-
- io.vertx.mutiny.core.streams.Pump
-
public class Pump extends Object
Pumps data from aReadStream
to aWriteStream
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 aWriteStream
. If data can be read faster than it can be written this could result in the write queue of theWriteStream
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, theReadStream
is paused, and adrainHandler
is set on theWriteStream
.When the
WriteStream
has processed half of its backlog, thedrainHandler
will be called, which results in the pump resuming theReadStream
.This class can be used to pump from any
ReadStream
to anyWriteStream
, e.g. from anHttpServerRequest
to anAsyncFile
, or fromNetSocket
to aWebSocket
.Please see the documentation for more information.
NOTE: This class has been automatically generated from theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Pump>
__TYPE_ARG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
io.vertx.core.streams.Pump
getDelegate()
int
hashCode()
static Pump
newInstance(io.vertx.core.streams.Pump arg)
int
numberPumped()
static <T> Pump
pump(ReadStream<T> rs, WriteStream<T> ws)
static <T> Pump
pump(ReadStream<T> rs, WriteStream<T> ws, int writeQueueMaxSize)
static <T> Pump
pump(org.reactivestreams.Publisher<T> rs, WriteStream<T> ws)
static <T> Pump
pump(org.reactivestreams.Publisher<T> rs, WriteStream<T> ws, int writeQueueMaxSize)
Pump
setWriteQueueMaxSize(int maxSize)
Pump
start()
Pump
stop()
String
toString()
-
-
-
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()
-
pump
public static <T> Pump pump(ReadStream<T> rs, WriteStream<T> ws)
- Parameters:
rs
- the read streamws
- the write stream- Returns:
- the pump
-
pump
public static <T> Pump pump(org.reactivestreams.Publisher<T> rs, WriteStream<T> ws)
- Parameters:
rs
- the read streamws
- the write stream- Returns:
- the pump
-
pump
public static <T> Pump pump(ReadStream<T> rs, WriteStream<T> ws, int writeQueueMaxSize)
- Parameters:
rs
- the read streamws
- the write streamwriteQueueMaxSize
- 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 streamws
- the write streamwriteQueueMaxSize
- 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)
-
-