Class BufferedClientStreamWriter<T> (4.2.0)

public class BufferedClientStreamWriter<T>
    where T : class

A wrapper around which removes the "one write at a time" restriction by buffering messages (and the completion signal) up to a given capacity.

Inheritance

Object > BufferedClientStreamWriter<T>

Namespace

Google.Api.Gax.Grpc

Assembly

Google.Api.Gax.Grpc.dll

Type Parameter

NameDescription
T

The type of message in the stream.

Constructors

BufferedClientStreamWriter(IClientStreamWriter<T>, Int32)

public BufferedClientStreamWriter(IClientStreamWriter<T> writer, int capacity)

Constructs an instance which writes to the specified writer, and with the given capacity.

Parameters
NameDescription
writerIClientStreamWriter<T>

The writer to delegate to.

capacityInt32

The maximum number of messages to buffer.

Methods

TryWriteAsync(T)

public Task TryWriteAsync(T message)

Writes a message to the stream, if there is enough space in the buffer and WriteCompleteAsync() hasn't already been called. The same write options will be used as for the previous message.

Parameter
NameDescription
messageT

The message to write.

Returns
TypeDescription
Task

null if the message queue is full or the stream has already been completed; otherwise, a Task which will complete when the message has been written to the stream.

TryWriteAsync(T, WriteOptions)

public Task TryWriteAsync(T message, WriteOptions options)

Writes a message to the stream, if there is enough space in the buffer and WriteCompleteAsync() hasn't already been called.

Parameters
NameDescription
messageT

The message to write.

optionsWriteOptions

The write options to use for this message.

Returns
TypeDescription
Task

null if the message queue is full or the stream has already been completed.

TryWriteCompleteAsync()

public Task TryWriteCompleteAsync()

Completes the stream when all buffered messages have been sent, if there is enough space in the buffer. This method can only be successfully called once, and further messages cannot be written after it has been successfully called.

Returns
TypeDescription
Task

null if this stream has already be completed, or if the buffer is full; otherwise a Task which will complete when the stream has finished being completed.

WriteAsync(T)

public Task WriteAsync(T message)

Writes a message to the stream, if there is enough space in the buffer and WriteCompleteAsync() hasn't already been called. The same write options will be used as for the previous message.

Parameter
NameDescription
messageT

The message to write.

Returns
TypeDescription
Task

A Task which will complete when the message has been written to the stream.

Exceptions
TypeDescription
InvalidOperationException

There isn't enough space left in the buffer, or the stream has been completed.

WriteAsync(T, WriteOptions)

public Task WriteAsync(T message, WriteOptions options)

Writes a message to the stream, if there is enough space in the buffer and WriteCompleteAsync() hasn't already been called.

Parameters
NameDescription
messageT

The message to write.

optionsWriteOptions

The write options to use for this message.

Returns
TypeDescription
Task

A Task which will complete when the message has been written to the stream.

Exceptions
TypeDescription
InvalidOperationException

There isn't enough space left in the buffer, or WriteCompleteAsync() has already been called.

WriteCompleteAsync()

public Task WriteCompleteAsync()

Completes the stream when all buffered messages have been sent, if there is enough space in the buffer. This method can only be successfully called once, and further messages cannot be written after it has been successfully called.

Returns
TypeDescription
Task

A Task which will complete when the stream has finished being completed.

Exceptions
TypeDescription
InvalidOperationException

This stream has already be completed, or the buffer is full