Class Pump
- java.lang.Object
-
- io.vertx.rxjava.core.streams.Pump
-
public class Pump extends Object
Pumps data from aReadStreamto aWriteStreamand performs flow control where necessary to prevent the write stream buffer from getting overfull.Instances of this class read items from a
ReadStreamand write them to aWriteStream. If data can be read faster than it can be written this could result in the write queue of theWriteStreamgrowing 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
WriteStreamis full, and if so, theReadStreamis paused, and adrainHandleris set on theWriteStream.When the
WriteStreamhas processed half of its backlog, thedrainHandlerwill be called, which results in the pump resuming theReadStream.This class can be used to pump from any
ReadStreamto anyWriteStream, e.g. from anHttpServerRequestto anAsyncFile, or fromNetSocketto aWebSocket.Please see the documentation for more information.
NOTE: This class has been automatically generated from theoriginalnon RX-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 booleanequals(Object o)PumpgetDelegate()inthashCode()static PumpnewInstance(Pump arg)intnumberPumped()Return the total number of items pumped by this pump.static <T> Pumppump(ReadStream<T> rs, WriteStream<T> ws)Create a newPumpwith the givenReadStreamandWriteStreamstatic <T> Pumppump(ReadStream<T> rs, WriteStream<T> ws, int writeQueueMaxSize)Create a newPumpwith the givenReadStreamandWriteStreamandwriteQueueMaxSizestatic <T> Pumppump(rx.Observable<T> rs, WriteStream<T> ws)Create a newPumpwith the givenReadStreamandWriteStreamstatic <T> Pumppump(rx.Observable<T> rs, WriteStream<T> ws, int writeQueueMaxSize)Create a newPumpwith the givenReadStreamandWriteStreamandwriteQueueMaxSizePumpsetWriteQueueMaxSize(int maxSize)Set the write queue max size tomaxSizePumpstart()Start the Pump.Pumpstop()Stop the Pump.StringtoString()
-
-
-
Method Detail
-
getDelegate
public Pump getDelegate()
-
pump
public static <T> Pump pump(ReadStream<T> rs, WriteStream<T> ws)
Create a newPumpwith the givenReadStreamandWriteStream- Parameters:
rs- the read streamws- the write stream- Returns:
- the pump
-
pump
public static <T> Pump pump(rx.Observable<T> rs, WriteStream<T> ws)
Create a newPumpwith the givenReadStreamandWriteStream- 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)
Create a newPumpwith the givenReadStreamandWriteStreamandwriteQueueMaxSize- Parameters:
rs- the read streamws- the write streamwriteQueueMaxSize- the max size of the write queue- Returns:
- the pump
-
pump
public static <T> Pump pump(rx.Observable<T> rs, WriteStream<T> ws, int writeQueueMaxSize)
Create a newPumpwith the givenReadStreamandWriteStreamandwriteQueueMaxSize- Parameters:
rs- the read streamws- the write streamwriteQueueMaxSize- the max size of the write queue- Returns:
- the pump
-
setWriteQueueMaxSize
public Pump setWriteQueueMaxSize(int maxSize)
Set the write queue max size tomaxSize- Parameters:
maxSize- the max size- Returns:
- a reference to this, so the API can be used fluently
-
start
public Pump start()
Start the Pump. The Pump can be started and stopped multiple times.- Returns:
- a reference to this, so the API can be used fluently
-
stop
public Pump stop()
Stop the Pump. The Pump can be started and stopped multiple times.- Returns:
- a reference to this, so the API can be used fluently
-
numberPumped
public int numberPumped()
Return the total number of items pumped by this pump.- Returns:
-
-