io.vertx.grpc

## Interface GrpcWriteStream<T>

- All Superinterfaces:
    StreamBase, WriteStream<T>
  All Known Subinterfaces:
    GrpcBidiExchange<I,O>, GrpcUniExchange<O,I>

      public interface GrpcWriteStream<T>
      extends WriteStream<T>

  Author:
    Paulo Lopes

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> GrpcWriteStream<T>` | `create(StreamObserver<T> observer)`
    `GrpcWriteStream<T>` | `drainHandler(Handler<Void> handler)` Set a drain handler on the stream.
    `GrpcWriteStream<T>` | `exceptionHandler(Handler<Throwable> handler)` Set an exception handler on the write stream.
    `GrpcWriteStream<T>` | `fail(Throwable t)` Send an error event into the stream.
    `GrpcWriteStream<T>` | `setWriteQueueMaxSize(int maxSize)` Set the maximum size of the write queue to `maxSize`.
    `GrpcWriteStream<T>` | `write(T data)` Write some data to the stream.
    `StreamObserver<T>` | `writeObserver()` Should not be used by end user, it is a simple accessor the the underlying gRPC StreamObserver.

    - ### Methods inherited from interface io.vertx.core.streams.WriteStream

      `end, end, writeQueueFull`

- - ### Method Detail

    - #### create

          static <T> GrpcWriteStream<T> create(StreamObserver<T> observer)

    - #### exceptionHandler

          GrpcWriteStream<T> exceptionHandler(Handler<Throwable> handler)

      Set an exception handler on the write stream.
      Specified by:
        `exceptionHandler` in interface `StreamBase`
      Specified by:
        `exceptionHandler` in interface `WriteStream<T>`
      Parameters:
        `handler` - the exception handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### write

          GrpcWriteStream<T> write(T data)

      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 `WriteStream.writeQueueFull()` method before writing. This is done automatically if using a `Pump`.
      Specified by:
        `write` in interface `WriteStream<T>`
      Parameters:
        `data` - the data to write
      Returns:
        a reference to this, so the API can be used fluently

    - #### setWriteQueueMaxSize

          GrpcWriteStream<T> setWriteQueueMaxSize(int maxSize)

      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 `NetSocket`, the number of `Message` for a `MessageProducer`, etc...
      Specified by:
        `setWriteQueueMaxSize` in interface `WriteStream<T>`
      Parameters:
        `maxSize` - the max size of the write stream
      Returns:
        a reference to this, so the API can be used fluently

    - #### drainHandler

          GrpcWriteStream<T> drainHandler(Handler<Void> handler)

      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`.
      Specified by:
        `drainHandler` in interface `WriteStream<T>`
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### fail

          GrpcWriteStream<T> fail(Throwable t)

      Send an error event into the stream.
      Parameters:
        `t` - any error
      Returns:
        a reference to this, so the API can be used fluently

    - #### writeObserver

          StreamObserver<T> writeObserver()

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

Copyright © 2017. All rights reserved.