vertx / io.vertx.grpc / GrpcWriteStream

GrpcWriteStream

interface GrpcWriteStream<T : Any> : WriteStream<T>

Author
Paulo Lopes

Functions

create

open static fun <T : Any> create(observer: StreamObserver<T>): GrpcWriteStream<T>

drainHandler

abstract fun drainHandler(handler: Handler<Void>): GrpcWriteStream<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 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.

exceptionHandler

abstract fun exceptionHandler(handler: Handler<Throwable>): GrpcWriteStream<T>

Set an exception handler on the write stream.

fail

abstract fun fail(t: Throwable): GrpcWriteStream<T>

Send an error event into the stream.

setWriteQueueMaxSize

abstract fun setWriteQueueMaxSize(maxSize: Int): GrpcWriteStream<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.core.net.NetSocket, the number of io.vertx.core.eventbus.Message for a io.vertx.core.eventbus.MessageProducer, etc...

write

abstract fun write(data: T): GrpcWriteStream<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 #writeQueueFull method before writing. This is done automatically if using a Pump.

writeObserver

abstract fun writeObserver(): StreamObserver<T>

Should not be used by end user, it is a simple accessor the the underlying gRPC StreamObserver.

Inheritors

GrpcBidiExchange

interface GrpcBidiExchange<I : Any, O : Any> : GrpcReadStream<I>, GrpcWriteStream<O>

GrpcUniExchange

interface GrpcUniExchange<O : Any, I : Any> : GrpcWriteStream<O>