| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Threading.Tasks; |
| | | 6 | | using dotnet_etcd.interfaces; |
| | | 7 | | using Grpc.Core; |
| | | 8 | | |
| | | 9 | | namespace dotnet_etcd; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Adapter for AsyncDuplexStreamingCall to implement IAsyncDuplexStreamingCall |
| | | 13 | | /// </summary> |
| | | 14 | | /// <typeparam name="TRequest">The request type</typeparam> |
| | | 15 | | /// <typeparam name="TResponse">The response type</typeparam> |
| | | 16 | | public class AsyncDuplexStreamingCallAdapter<TRequest, TResponse> : IAsyncDuplexStreamingCall<TRequest, TResponse> |
| | | 17 | | { |
| | | 18 | | private readonly AsyncDuplexStreamingCall<TRequest, TResponse> _call; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Initializes a new instance of the <see cref="AsyncDuplexStreamingCallAdapter{TRequest, TResponse}" /> class. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="call">The underlying call to wrap</param> |
| | | 24 | | /// <exception cref="ArgumentNullException">Thrown if call is null</exception> |
| | 0 | 25 | | public AsyncDuplexStreamingCallAdapter(AsyncDuplexStreamingCall<TRequest, TResponse> call) => |
| | 0 | 26 | | _call = call ?? throw new ArgumentNullException(nameof(call)); |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | 0 | 29 | | public IClientStreamWriter<TRequest> RequestStream => _call.RequestStream; |
| | | 30 | | |
| | | 31 | | /// <inheritdoc /> |
| | 0 | 32 | | public IAsyncStreamReader<TResponse> ResponseStream => _call.ResponseStream; |
| | | 33 | | |
| | | 34 | | /// <inheritdoc /> |
| | 0 | 35 | | public Task<Metadata> GetHeadersAsync() => _call.ResponseHeadersAsync; |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | 0 | 38 | | public Status GetStatus() => _call.GetStatus(); |
| | | 39 | | |
| | | 40 | | /// <inheritdoc /> |
| | 0 | 41 | | public Metadata GetTrailers() => _call.GetTrailers(); |
| | | 42 | | |
| | | 43 | | /// <inheritdoc /> |
| | | 44 | | public void Dispose() |
| | 0 | 45 | | { |
| | 0 | 46 | | _call.Dispose(); |
| | 0 | 47 | | GC.SuppressFinalize(this); |
| | 0 | 48 | | } |
| | | 49 | | } |