Pipe

Pipe data from a @see \io\vertx\jphp\core\streams\ReadStream to a @see \io\vertx\jphp\core\streams\WriteStream and performs flow control where necessary to prevent the write stream buffer from getting overfull.

Instances of this class read items from a @see \io\vertx\jphp\core\streams\ReadStream and write them to a @see \io\vertx\jphp\core\streams\WriteStream. If data can be read faster than it can be written this could result in the write queue of the @see \io\vertx\jphp\core\streams\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 @see \io\vertx\jphp\core\streams\WriteStream is full, and if so, the @see \io\vertx\jphp\core\streams\ReadStream is paused, and a drainHandler is set on the

see

When the @see \io\vertx\jphp\core\streams\WriteStream has processed half of its backlog, the drainHandler will be called, which results in the pump resuming the @see \io\vertx\jphp\core\streams\ReadStream.

This class can be used to pipe from any @see \io\vertx\jphp\core\streams\ReadStream to any @see \io\vertx\jphp\core\streams\WriteStream, e.g. from an @see \io\vertx\jphp\core\http\HttpServerRequest to an @see \io\vertx\jphp\core\file\AsyncFile, or from @see \io\vertx\jphp\core\net\NetSocket to a @see \io\vertx\jphp\core\http\WebSocket.

Please see the documentation for more information.

package

Default

Methods

__construct

__construct() 

Close the pipe.

close() : void

The streams handlers will be unset and the read stream resumed unless it is already ended.

Set to <code>true</code> to call @see \io\vertx\jphp\core\streams\WriteStream::end when the source <code>ReadStream</code> completes, <code>false</code> otherwise.

endOnComplete( $arg0) : $this

Calling this overwrites @see \io\vertx\jphp\core\streams\Pipe::endOnFailure and @see \io\vertx\jphp\core\streams\Pipe::endOnSuccess.

Arguments

$arg0

boolean

Response

$this

a reference to this, so the API can be used fluently

Set to <code>true</code> to call @see \io\vertx\jphp\core\streams\WriteStream::end when the source <code>ReadStream</code> fails, <code>false</code> otherwise.

endOnFailure( $arg0) : $this

Arguments

$arg0

boolean

Response

$this

a reference to this, so the API can be used fluently

Set to <code>true</code> to call @see \io\vertx\jphp\core\streams\WriteStream::end when the source <code>ReadStream</code> succeeds, <code>false</code> otherwise.

endOnSuccess( $arg0) : $this

Arguments

$arg0

boolean

Response

$this

a reference to this, so the API can be used fluently

Like @see \io\vertx\jphp\core\streams\Pipe::to but without a completion handler

to( $arg0,  $arg1 = null) : void

param $dst [WriteStream] to($dst)

Start to pipe the elements to the destination WriteStream.

When the operation fails with a write error, the source stream is resumed. param $dst [WriteStream] the destination write stream param $completionHandler [callable] the handler called when the pipe operation completes to($dst, $completionHandler)

Arguments

$arg0

WriteStream

$arg1

callable