[#19] Client: Use specific classes for search
Signed-off-by: Pavel Gross <p.gross@yando.com>
This commit is contained in:
parent
3206abc33e
commit
35fe791406
27 changed files with 320 additions and 123 deletions
|
@ -1,33 +1,25 @@
|
|||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.Container;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using System.Collections.Generic;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.Refs;
|
||||
using System;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using System.Collections.Specialized;
|
||||
using FrostFS.Refs;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
internal class ContainerServiceProvider : ContextAccessor
|
||||
internal class ContainerServiceProvider(ContainerService.ContainerServiceClient service, ClientEnvironment context) : ContextAccessor(context)
|
||||
{
|
||||
private readonly ContainerService.ContainerServiceClient containerServiceClient;
|
||||
|
||||
internal ContainerServiceProvider(ContainerService.ContainerServiceClient service, ClientEnvironment context)
|
||||
: base(context)
|
||||
{
|
||||
containerServiceClient = service;
|
||||
}
|
||||
|
||||
internal async Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args)
|
||||
{
|
||||
GetRequest request = GetContainerRequest(args.ContainerId.ToGrpcMessage(), args.XHeaders);
|
||||
|
||||
var response = await containerServiceClient.GetAsync(request, null, args.Context!.Deadline, args.Context.CancellationToken);
|
||||
var response = await service.GetAsync(request, null, args.Context!.Deadline, args.Context.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -49,7 +41,7 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(Context.Key);
|
||||
|
||||
var response = await containerServiceClient.ListAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.ListAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -74,11 +66,11 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
Signature = Context.Key.SignRFC6979(grpcContainer)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(Context.Key);
|
||||
|
||||
var response = await containerServiceClient.PutAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.PutAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -98,11 +90,12 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
Signature = Context.Key.SignRFC6979(args.ContainerId.ToGrpcMessage().Value)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
|
||||
request.Sign(Context.Key);
|
||||
|
||||
var response = await containerServiceClient.DeleteAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.DeleteAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
await WaitForContainer(WaitExpects.Removed, request.Body.ContainerId, args.WaitParams, ctx);
|
||||
|
||||
|
@ -137,7 +130,7 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
|
||||
async Task action()
|
||||
{
|
||||
var response = await containerServiceClient.GetAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.GetAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
Verifier.CheckResponse(response);
|
||||
}
|
||||
|
||||
|
@ -148,7 +141,7 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
Func<Task> action,
|
||||
WaitExpects expect,
|
||||
PrmWait? waitParams)
|
||||
{
|
||||
{
|
||||
waitParams ??= PrmWait.DefaultParams;
|
||||
var deadLine = waitParams.GetDeadline();
|
||||
|
||||
|
@ -160,7 +153,10 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
|
||||
if (expect == WaitExpects.Exists)
|
||||
return;
|
||||
|
||||
|
||||
if (DateTime.UtcNow >= deadLine)
|
||||
throw new TimeoutException();
|
||||
|
||||
await Task.Delay(waitParams.PollInterval);
|
||||
}
|
||||
catch (ResponseException ex)
|
||||
|
@ -173,11 +169,9 @@ internal class ContainerServiceProvider : ContextAccessor
|
|||
|
||||
if (expect == WaitExpects.Removed)
|
||||
return;
|
||||
|
||||
|
||||
await Task.Delay(waitParams.PollInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue