frostfs-sdk-csharp/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs
Pavel Gross d1271df207
All checks were successful
DCO / DCO (pull_request) Successful in 35s
[#13] Client: Use code analyzers
Signed-off-by: Pavel Gross <p.gross@yadro.com>
2024-09-23 19:25:59 +03:00

34 lines
No EOL
819 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 sealed 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).ConfigureAwait(false))
return null;
var response = Call.ResponseStream.Current;
Verifier.CheckResponse(response);
return response.Body?.IdList.ToList();
}
public void Dispose()
{
Call?.Dispose();
}
}