Fixed: Dispose the gRPC call underlying a Read if the read is only partially consumed
e.g. when early returning from an await foreach or calling .First().
The IAsyncEnumerable is disposed as before, but now that causes the cancellation of the ResponseStream read, so PumpMessages completes and the call is disposed.
The CancellationTokenSource need not be disposed because it is always cancelled (That is, as long as the user makes any attempt to consume the read - if they don't then the call remains open as before)
Note, I did attempt to remove the channel, but the ReadState task is populated proactively, without the user needing to start consuming the read, so simply having IAsyncEnumerables isn't so straight forward.
Fixed: Dispose the gRPC call underlying a Read if the read is only partially consumed
e.g. when early returning from an await foreach or calling .First().
The IAsyncEnumerable is disposed as before, but now that causes the cancellation of the ResponseStream read, so PumpMessages completes and the call is disposed.
The CancellationTokenSource need not be disposed because it is always cancelled (That is, as long as the user makes any attempt to consume the read - if they don't then the call remains open as before)
Note, I did attempt to remove the channel, but the ReadState task is populated proactively, without the user needing to start consuming the read, so simply having IAsyncEnumerables isn't so straight forward.
Fixes: https://github.com/EventStore/EventStore-Client-Dotnet/issues/219