You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gRPC has a `stream` concept that allows client-streaming, server-streaming, and full-duplex (independent bidirectional) streaming of messages. Inside
4
+
protobuf-net.Grpc, this is typically exposed via the `IAsyncEnumerable<T>` API, which is an asynchronous sequence of messages of type `T`. For example,
5
+
6
+
```
7
+
public async IAsyncEnumerable<SomeResponse> SomeDuplexMethod(IAsyncEnumerable<SomeRequest> requests)
8
+
{
9
+
// very basic request/response server using streaming
10
+
await foreach (var req in requests)
11
+
{
12
+
yield return ApplySomeTransformation(req);
13
+
}
14
+
}
15
+
```
16
+
17
+
This is *fine*, but .NET has another "stream", i.e. `System.IO.Stream` - a sequence of *bytes*.
18
+
19
+
As of 1.2.2, protobuf-net.Grpc has limited (and growing) support for `Stream` as an exchange mechanism. Currently supported scenarios:
20
+
21
+
-`Task<Stream> SomeMethod(/* optional single request message, optional context/cancellation */);`
22
+
-`ValueTask<Stream> SomeMethod(/* optional single request message, optional context/cancellation */);`
This hands a `Stream` back to the library, with the library assuming control of how to transmit that, disposing the stream when done (as an implementation detail: it
36
+
is sent as a `stream` of [`BytesValue`](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto) messages,
37
+
with bespoke marshalling). As you would expect, the client can access this data trivially:
0 commit comments