[] Add cancellation token to GetChank method

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2024-06-26 15:24:15 +03:00
parent f5d1899dd2
commit 17492ee871
2 changed files with 6 additions and 4 deletions
src
FrostFS.SDK.ClientV2/Services
FrostFS.SDK.ModelsV2/Object

View file

@ -5,6 +5,7 @@ using Grpc.Core;
using FrostFS.Object; using FrostFS.Object;
using FrostFS.SDK.ModelsV2; using FrostFS.SDK.ModelsV2;
using System.Threading;
namespace FrostFS.SDK.ClientV2; namespace FrostFS.SDK.ClientV2;
@ -32,9 +33,9 @@ public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectR
}; };
} }
public async Task<byte[]?> ReadChunk() public async Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default)
{ {
if (!await Call.ResponseStream.MoveNext()) if (!await Call.ResponseStream.MoveNext(cancellationToken))
return null; return null;
var response = Call.ResponseStream.Current; var response = Call.ResponseStream.Current;

View file

@ -1,9 +1,10 @@
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ModelsV2;
public interface IObjectReader : IDisposable public interface IObjectReader : IDisposable
{ {
Task<byte[]?> ReadChunk(); Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default);
} }