Show / Hide Table of Contents

Class BufferedClientStreamWriter<T>

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

Inheritance
System.Object
BufferedClientStreamWriter<T>
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Api.Gax.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public class BufferedClientStreamWriter<T>
    where T : class
Type Parameters
Name Description
T

The type of message in the stream.

Constructors

BufferedClientStreamWriter(IClientStreamWriter<T>, Int32)

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

Declaration
public BufferedClientStreamWriter(IClientStreamWriter<T> writer, int capacity)
Parameters
Type Name Description
IClientStreamWriter<T> writer

The writer to delegate to.

System.Int32 capacity

The maximum number of messages to buffer.

Methods

TryWriteAsync(T)

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.

Declaration
public Task TryWriteAsync(T message)
Parameters
Type Name Description
T message

The message to write.

Returns
Type Description
System.Threading.Tasks.Task

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

TryWriteAsync(T, WriteOptions)

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

Declaration
public Task TryWriteAsync(T message, WriteOptions options)
Parameters
Type Name Description
T message

The message to write.

WriteOptions options

The write options to use for this message.

Returns
Type Description
System.Threading.Tasks.Task

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

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.

Declaration
public Task TryWriteCompleteAsync()
Returns
Type Description
System.Threading.Tasks.Task

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

WriteAsync(T)

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.

Declaration
public Task WriteAsync(T message)
Parameters
Type Name Description
T message

The message to write.

Returns
Type Description
System.Threading.Tasks.Task

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

Exceptions
Type Condition
System.InvalidOperationException

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

WriteAsync(T, WriteOptions)

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

Declaration
public Task WriteAsync(T message, WriteOptions options)
Parameters
Type Name Description
T message

The message to write.

WriteOptions options

The write options to use for this message.

Returns
Type Description
System.Threading.Tasks.Task

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

Exceptions
Type Condition
System.InvalidOperationException

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

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.

Declaration
public Task WriteCompleteAsync()
Returns
Type Description
System.Threading.Tasks.Task

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

Exceptions
Type Condition
System.InvalidOperationException

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

Back to top