public abstract class BidirectionalStreamingBase<TRequest, TResponse>
Base class for bidirectional streaming RPC methods.
Namespace
GoogleGoogle.ApiGaxGrpcAssembly
Google.Api.Gax.Grpc.dll
Type Parameters | |
---|---|
Name | Description |
TRequest | RPC request type |
TResponse | RPC response type |
Properties
GrpcCall
public virtual AsyncDuplexStreamingCall<TRequest, TResponse> GrpcCall { get; }
The underlying gRPC duplex 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 | |
---|---|
Type | Description |
AsyncDuplexStreamingCall<, > |
Methods
GetResponseStream()
public virtual AsyncResponseStream<TResponse> GetResponseStream()
Async stream to read streaming responses, exposed as an async sequence. The default implementation will use GrpcCall to extract a response stream, and adapt it to AsyncResponseStream<TResponse>.
Returns | |
---|---|
Type | Description |
AsyncResponseStream |
If this method is called more than once, all the returned enumerators will be enumerating over the same underlying response stream, which may cause confusion. Additionally, the sequence returned by this method can only be iterated over a single time. Attempting to iterate more than once will cause an InvalidOperationException.
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 | |
---|---|
Name | Description |
message | TRequest The message to write. |
Returns | |
---|---|
Type | Description |
Task |
|
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 | |
---|---|
Name | Description |
message | TRequest The message to write. |
options | WriteOptions The write options to use for this message. |
Returns | |
---|---|
Type | Description |
Task |
|
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 | |
---|---|
Type | Description |
Task | A Task which will complete when the stream has finished being completed;
or |
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 | |
---|---|
Name | Description |
message | TRequest The message to write. |
Returns | |
---|---|
Type | Description |
Task | A Task which will complete when the message has been written to the stream. |
Exceptions | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
message | TRequest The message to write. |
options | WriteOptions The write options to use for this message. |
Returns | |
---|---|
Type | Description |
Task | A Task which will complete when the message has been written to the stream. |
Exceptions | |
---|---|
Type | Description |
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 | |
---|---|
Type | Description |
Task | A Task which will complete when the stream has finished being completed. |
Exceptions | |
---|---|
Type | Description |
InvalidOperationException | This method has already been called. |