package streams
- Alphabetic
- Public
- All
Type Members
-
class
Pump extends AnyRef
Pumps data from a io.vertx.scala.core.streams.ReadStream to a io.vertx.scala.core.streams.WriteStream and performs flow control where necessary to prevent the write stream buffer from getting overfull.
Pumps data from a io.vertx.scala.core.streams.ReadStream to a io.vertx.scala.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 io.vertx.scala.core.streams.ReadStream and write them to a io.vertx.scala.core.streams.WriteStream. If data can be read faster than it can be written this could result in the write queue of the io.vertx.scala.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 io.vertx.scala.core.streams.WriteStream is full, and if so, the io.vertx.scala.core.streams.ReadStream is paused, and a
drainHandler
is set on the io.vertx.scala.core.streams.WriteStream.When the io.vertx.scala.core.streams.WriteStream has processed half of its backlog, the
drainHandler
will be called, which results in the pump resuming the io.vertx.scala.core.streams.ReadStream.This class can be used to pump from any io.vertx.scala.core.streams.ReadStream to any io.vertx.scala.core.streams.WriteStream, e.g. from an io.vertx.scala.core.http.HttpServerRequest to an io.vertx.scala.core.file.AsyncFile, or from io.vertx.scala.core.net.NetSocket to a io.vertx.scala.core.http.WebSocket.
Please see the documentation for more information.
-
trait
ReadStream[T] extends StreamBase
Represents a stream of items that can be read from.
Represents a stream of items that can be read from.
Any class that implements this interface can be used by a io.vertx.scala.core.streams.Pump to pump data from it to a io.vertx.scala.core.streams.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 io.vertx.scala.core.streams.ReadStream#pause, io.vertx.scala.core.streams.ReadStream#resume and io.vertx.scala.core.streams.ReadStream#fetch methods:
- Calling io.vertx.scala.core.streams.ReadStream#resume sets the flowing mode
- Calling io.vertx.scala.core.streams.ReadStream#pause sets the fetch mode and resets the demand to
0
- Calling io.vertx.scala.core.streams.ReadStream#fetch requests a specific amount of elements and adds it to the actual demand
- When the stream is in flowing mode, elements are delivered to the
-
trait
StreamBase extends AnyRef
Base interface for a stream.
-
trait
WriteStream[T] extends StreamBase
Represents a stream of data that can be written to.
Represents a stream of data that can be written to.
Any class that implements this interface can be used by a io.vertx.scala.core.streams.Pump to pump data from a
ReadStream
to it.
Value Members
- object Pump
- object ReadStream
- object StreamBase
- object WriteStream