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
Copy file name to clipboardexpand all lines: docs/streams.md
+16-5
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ gRPC has a `stream` concept that allows client-streaming, server-streaming, and
4
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
5
6
6
```
7
-
public async IAsyncEnumerable<SomeResponse> SomeDuplexMethod(IAsyncEnumerable<SomeRequest> requests)
7
+
public async IAsyncEnumerable<SomeResponse> SomeDuplexMethod(
8
+
IAsyncEnumerable<SomeRequest> requests)
8
9
{
9
10
// very basic request/response server using streaming
10
11
await foreach (var req in requests)
@@ -18,25 +19,35 @@ This is *fine*, but .NET has another "stream", i.e. `System.IO.Stream` - a seque
18
19
19
20
As of 1.2.2, protobuf-net.Grpc has limited (and growing) support for `Stream` as an exchange mechanism. Currently supported scenarios:
20
21
21
-
-`Task<Stream> SomeMethod(/* optional single request message, optional context/cancellation */);`
22
-
-`ValueTask<Stream> SomeMethod(/* optional single request message, optional context/cancellation */);`
22
+
-```
23
+
Task<Stream> SomeMethod(/* optional single request message,
24
+
optional context/cancellation */);
25
+
```
26
+
-```
27
+
ValueTask<Stream> SomeMethod(/* optional single request message,
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
44
+
This hands a `Stream` back to the library, with the library assuming control of how to transmit that, disposing the stream when done, and
45
+
handling faults in the expected ways (as an implementation detail: it
36
46
is sent as a `stream` of [`BytesValue`](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto) messages,
37
47
with bespoke marshalling). As you would expect, the client can access this data trivially:
38
48
39
49
```c#
50
+
// write Stream data from gRPC server to a local file
0 commit comments