vertx / io.vertx.reactivex.core.streams / WriteStream

# WriteStream

`interface WriteStream<T : Any> : StreamBase`

Represents a stream of data that can be written to.

Any class that implements this interface can be used by a io.vertx.reactivex.core.streams.Pump to pump data from a `ReadStream` to it.

NOTE: This class has been automatically generated from the io.vertx.core.streams.WriteStream non RX-ified interface using Vert.x codegen.

### Functions

drainHandler | `abstract fun drainHandler(handler: Handler<Void>): WriteStream<T>` Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See io.vertx.reactivex.core.streams.Pump for an example of this being used. The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to `maxSize / 2`.
end | `abstract fun end(): Unit` Ends the stream. Once the stream has ended, it cannot be used any more. `abstract fun end(t: T): Unit` Same as `io.vertx.reactivex.core.streams.WriteStream#end` but writes some data to the stream before ending.
exceptionHandler | `abstract fun exceptionHandler(handler: Handler<Throwable>): WriteStream<T>` Set an exception handler on the write stream.
getDelegate | `abstract fun getDelegate(): WriteStream<Any>`
newInstance | `open static fun <T : Any> newInstance(arg: WriteStream<Any>): WriteStream<T>` `open static fun <T : Any> newInstance(arg: WriteStream<Any>, __typeArg_T: TypeArg<T>): WriteStream<T>`
setWriteQueueMaxSize | `abstract fun setWriteQueueMaxSize(maxSize: Int): WriteStream<T>` Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` items in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control. The value is defined by the implementation of the stream, e.g in bytes for a io.vertx.reactivex.core.net.NetSocket, the number of io.vertx.reactivex.core.eventbus.Message for a io.vertx.reactivex.core.eventbus.MessageProducer, etc...
write | `abstract fun write(data: T): WriteStream<T>` Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the `io.vertx.reactivex.core.streams.WriteStream#writeQueueFull` method before writing. This is done automatically if using a io.vertx.reactivex.core.streams.Pump.
writeQueueFull | `abstract fun writeQueueFull(): Boolean` This will return `true` if there are more bytes in the write queue than the value set using `io.vertx.reactivex.core.streams.WriteStream#setWriteQueueMaxSize`

### Inheritors

AsyncFile | `open class AsyncFile : ReadStream<Buffer>, WriteStream<Buffer>` Represents a file on the file-system which can be read from, or written to asynchronously. This class also implements io.vertx.reactivex.core.streams.ReadStream and io.vertx.reactivex.core.streams.WriteStream. This allows the data to be pumped to and from other streams, e.g. an io.vertx.reactivex.core.http.HttpClientRequest instance, using the io.vertx.reactivex.core.streams.Pump class NOTE: This class has been automatically generated from the io.vertx.core.file.AsyncFile non RX-ified interface using Vert.x codegen.
HttpClientRequest | `open class HttpClientRequest : WriteStream<Buffer>, ReadStream<HttpClientResponse>` Represents a client-side HTTP request. Instances are created by an io.vertx.reactivex.core.http.HttpClient instance, via one of the methods corresponding to the specific HTTP methods, or the generic request methods. On creation the request will not have been written to the wire. Once a request has been obtained, headers can be set on it, and data can be written to its body if required. Once you are ready to send the request, one of the `io.vertx.reactivex.core.http.HttpClientRequest#end` methods should be called. Nothing is actually sent until the request has been internally assigned an HTTP connection. The io.vertx.reactivex.core.http.HttpClient instance will return an instance of this class immediately, even if there are no HTTP connections available in the pool. Any requests sent before a connection is assigned will be queued internally and actually sent when an HTTP connection becomes available from the pool. The headers of the request are queued for writing either when the `io.vertx.reactivex.core.http.HttpClientRequest#end` method is called, or, when the first part of the body is written, whichever occurs first. This class supports both chunked and non-chunked HTTP. It implements io.vertx.reactivex.core.streams.WriteStream so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control. An example of using this class is as follows: NOTE: This class has been automatically generated from the io.vertx.core.http.HttpClientRequest non RX-ified interface using Vert.x codegen.
HttpServerResponse | `open class HttpServerResponse : WriteStream<Buffer>` Represents a server-side HTTP response. An instance of this is created and associated to every instance of io.vertx.reactivex.core.http.HttpServerRequest that. It allows the developer to control the HTTP response that is sent back to the client for a particular HTTP request. It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response. It also allows files to be streamed by the kernel directly from disk to the outgoing HTTP connection, bypassing user space altogether (where supported by the underlying operating system). This is a very efficient way of serving files from the server since buffers do not have to be read one by one from the file and written to the outgoing socket. It implements io.vertx.reactivex.core.streams.WriteStream so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control. NOTE: This class has been automatically generated from the io.vertx.core.http.HttpServerResponse non RX-ified interface using Vert.x codegen.
KafkaProducer | `open class KafkaProducer<K : Any, V : Any> : WriteStream<KafkaProducerRecord<K, V>>` Vert.x Kafka producer. The provides global control over writing a record. NOTE: This class has been automatically generated from the io.vertx.kafka.client.producer.KafkaProducer non RX-ified interface using Vert.x codegen.
MessageProducer | `open class MessageProducer<T : Any> : WriteStream<T>` Represents a stream of message that can be written to. NOTE: This class has been automatically generated from the io.vertx.core.eventbus.MessageProducer non RX-ified interface using Vert.x codegen.
NetSocket | `open class NetSocket : ReadStream<Buffer>, WriteStream<Buffer>` Represents a socket-like interface to a TCP connection on either the client or the server side. Instances of this class are created on the client side by an io.vertx.reactivex.core.net.NetClient when a connection to a server is made, or on the server side by a io.vertx.reactivex.core.net.NetServer when a server accepts a connection. It implements both and so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control. NOTE: This class has been automatically generated from the io.vertx.core.net.NetSocket non RX-ified interface using Vert.x codegen.
WebSocketBase | `interface WebSocketBase : ReadStream<Buffer>, WriteStream<Buffer>` Base WebSocket implementation. It implements both and so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control. NOTE: This class has been automatically generated from the io.vertx.core.http.WebSocketBase non RX-ified interface using Vert.x codegen.