frostfs-sdk-csharp/src/FrostFS.SDK.ClientV2/Services/ObjectStreamer.cs
p.gross 0c4723c705 [#3] Move to netstandard 2.0
Signed-off-by: Pavel Gross <p.gross@yadro.com>
2024-05-30 11:47:51 +03:00

35 lines
765 B
C#

using System;
using System.Threading.Tasks;
using Grpc.Core;
using FrostFS.Object;
namespace FrostFS.SDK.ClientV2;
internal class ObjectStreamer(AsyncClientStreamingCall<PutRequest, PutResponse> call) : IDisposable
{
public AsyncClientStreamingCall<PutRequest, PutResponse> Call { get; private set; } = call;
public async Task Write(PutRequest request)
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
await Call.RequestStream.WriteAsync(request);
}
public async Task<PutResponse> Close()
{
await Call.RequestStream.CompleteAsync();
return await Call.ResponseAsync;
}
public void Dispose()
{
Call.Dispose();
}
}