public class ServerStreamingBase<TResponse> : IDisposable
Base class for server streaming RPC methods. This wraps an underlying call returned by gRPC, in order to provide a wrapper for the async response stream, allowing users to take advantage of
await foreach
Implements
IDisposableNamespace
Google.Api.Gax.GrpcAssembly
Google.Api.Gax.Grpc.dll
Type Parameter |
|
---|---|
Name | Description |
TResponse |
RPC streaming response type |
Remarks
To avoid memory leaks, users must dispose of gRPC streams. Additionally, you are strongly advised to read the whole response stream, even if the data is not required - this avoids effectively cancelling the call.
Properties
GrpcCall
public virtual AsyncServerStreamingCall<TResponse> GrpcCall { get; }
The underlying gRPC duplex streaming call.
Property Value | |
---|---|
Type | Description |
AsyncServerStreamingCall |
Methods
Dispose()
public virtual void Dispose()
Disposes of the underlying gRPC call. There is no need to dispose of both the wrapper and the underlying call; it's typically simpler to dispose of the wrapper with a
using
The default implementation just calls Dispose on the result of GrpcCall.
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.