[#13] Change GetObject result to stream #12
2 changed files with 6 additions and 4 deletions
|
@ -5,13 +5,14 @@ using Grpc.Core;
|
|||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Threading;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectReader
|
||||
{
|
||||
private bool disposed = false;
|
||||
|
||||
|
||||
public AsyncServerStreamingCall<GetResponse> Call { get; private set; } = call;
|
||||
|
||||
internal async Task<Object.Object> ReadHeader()
|
||||
|
@ -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;
|
||||
|
||||
var response = Call.ResponseStream.Current;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public interface IObjectReader : IDisposable
|
||||
{
|
||||
Task<byte[]?> ReadChunk();
|
||||
Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue