frostfs-sdk-csharp/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs
Pavel Gross 6562aa27a5 [#23] Client: Refactoring to optimize memory usage
Signed-off-by: Pavel Gross <p.gross@yando.com>
2024-09-11 10:58:00 +03:00

34 lines
No EOL
805 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using FrostFS.Object;
using FrostFS.Refs;
using Grpc.Core;
namespace FrostFS.SDK.ClientV2;
internal class SearchReader(AsyncServerStreamingCall<SearchResponse> call) : IDisposable
{
public AsyncServerStreamingCall<SearchResponse> Call { get; private set; } = call;
public async Task<List<ObjectID>?> Read(CancellationToken cancellationToken)
{
if (!await Call.ResponseStream.MoveNext(cancellationToken))
return null;
var response = Call.ResponseStream.Current;
Verifier.CheckResponse(response);
return response.Body?.IdList.ToList();
}
public void Dispose()
{
Call?.Dispose();
}
}