[#13] Change GetObject result to stream

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2024-06-26 15:15:58 +03:00
parent c988ff3c76
commit f5d1899dd2
5 changed files with 75 additions and 34 deletions

View file

@ -4,14 +4,17 @@ using System.Threading.Tasks;
using Grpc.Core;
using FrostFS.Object;
using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2;
internal class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IDisposable
public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectReader
{
private bool disposed = false;
public AsyncServerStreamingCall<GetResponse> Call { get; private set; } = call;
public async Task<Object.Object> ReadHeader()
internal async Task<Object.Object> ReadHeader()
{
if (!await Call.ResponseStream.MoveNext())
throw new InvalidOperationException("unexpected end of stream");
@ -45,6 +48,12 @@ internal class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IDispo
public void Dispose()
{
Call.Dispose();
if (!disposed)
{
Call.Dispose();
GC.SuppressFinalize(this);
disposed = true;
}
}
}