Class ClientStreamingBase<TRequest, TResponse> (4.3.1)

public abstract class ClientStreamingBase<TRequest, TResponse>

Base class for the client-side streaming RPC methods.

Inheritance

object > ClientStreamingBase<TRequest, TResponse>

Namespace

GoogleGoogle.ApiGaxGrpc

Assembly

Google.Api.Gax.Grpc.dll

Type Parameters

NameDescription
TRequest

RPC request type

TResponse

RPC response type

Properties

GrpcCall

public virtual AsyncClientStreamingCall<TRequest, TResponse> GrpcCall { get; }

The underlying gRPC client streaming call. Warning: DO NOT USE GrpcCall.RequestStream at all if using TryWriteAsync(TRequest), WriteAsync(TRequest), TryWriteAsync(TRequest, WriteOptions) , or WriteAsync(TRequest, WriteOptions). Doing so will cause conflict with the write-buffer used within the [Try]WriteAsync methods.

Property Value
TypeDescription
AsyncClientStreamingCall<, >

ResponseAsync

public Task<TResponse> ResponseAsync { get; }

Asynchronous call result. This task will only complete after WriteCompleteAsync() has already been called.

Property Value
TypeDescription
Task

A task representing the asynchronous operation. The result of the completed task will be the RPC response.

Methods

TryWriteAsync(TRequest)

public virtual Task TryWriteAsync(TRequest 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
messageTRequest

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(TRequest, WriteOptions)

public virtual Task TryWriteAsync(TRequest 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
messageTRequest

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 virtual Task TryWriteCompleteAsync()

Completes the stream when all buffered messages have been sent. Only the first call to this method on any instance will have any effect; subsequent calls will return null.

Returns
TypeDescription
Task

A Task which will complete when the stream has finished being completed; or null if this method has already been called.

WriteAsync(TRequest)

public virtual Task WriteAsync(TRequest 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
messageTRequest

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 WriteCompleteAsync() has already been called.

WriteAsync(TRequest, WriteOptions)

public virtual Task WriteAsync(TRequest 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
messageTRequest

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 virtual Task WriteCompleteAsync()

Completes the stream when all buffered messages have been sent. This method can only be called once, and further messages cannot be written after it has been called.

Returns
TypeDescription
Task

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

Exceptions
TypeDescription
InvalidOperationException

This method has already been called.