[#28] Clients: Make immutable parameters
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
749000a090
commit
9bb7b5eff8
62 changed files with 2742 additions and 963 deletions
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -38,21 +37,19 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
return token;
|
||||
}
|
||||
|
||||
internal async Task<FrostFsContainerInfo> GetContainerAsync(PrmContainerGet args)
|
||||
internal async Task<FrostFsContainerInfo> GetContainerAsync(PrmContainerGet args, CallContext ctx)
|
||||
{
|
||||
GetRequest request = GetContainerRequest(args.Container.ContainerID, args.XHeaders, ClientContext.Key.ECDsaKey);
|
||||
|
||||
var response = await service.GetAsync(request, null, args.Context.Deadline, args.Context.CancellationToken);
|
||||
var response = await service.GetAsync(request, null, ctx.GetDeadline(), ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
return response.Body.Container.ToModel();
|
||||
}
|
||||
|
||||
internal async IAsyncEnumerable<FrostFsContainerId> ListContainersAsync(PrmContainerGetAll args)
|
||||
internal async IAsyncEnumerable<FrostFsContainerId> ListContainersAsync(PrmContainerGetAll args, CallContext ctx)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
|
||||
var request = new ListRequest
|
||||
{
|
||||
Body = new()
|
||||
|
@ -64,7 +61,7 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(ClientContext.Key.ECDsaKey);
|
||||
|
||||
var response = await service.ListAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.ListAsync(request, null, ctx.GetDeadline(), ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -74,10 +71,8 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
}
|
||||
}
|
||||
|
||||
internal async Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args)
|
||||
internal async Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
|
||||
var grpcContainer = args.Container.GetContainer();
|
||||
|
||||
grpcContainer.OwnerId ??= ClientContext.Owner.OwnerID;
|
||||
|
@ -103,7 +98,7 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
|
||||
request.Sign(ClientContext.Key.ECDsaKey);
|
||||
|
||||
var response = await service.PutAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.PutAsync(request, null, ctx.GetDeadline(), ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -112,10 +107,8 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
return new FrostFsContainerId(response.Body.ContainerId);
|
||||
}
|
||||
|
||||
internal async Task DeleteContainerAsync(PrmContainerDelete args)
|
||||
internal async Task DeleteContainerAsync(PrmContainerDelete args, CallContext ctx)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
|
||||
var request = new DeleteRequest
|
||||
{
|
||||
Body = new DeleteRequest.Types.Body
|
||||
|
@ -136,7 +129,7 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
|
||||
request.Sign(ClientContext.Key.ECDsaKey);
|
||||
|
||||
var response = await service.DeleteAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.DeleteAsync(request, null, ctx.GetDeadline(), ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
|
@ -146,7 +139,7 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
Verifier.CheckResponse(response);
|
||||
}
|
||||
|
||||
private static GetRequest GetContainerRequest(ContainerID id, NameValueCollection? xHeaders, ECDsa key)
|
||||
private static GetRequest GetContainerRequest(ContainerID id, string[] xHeaders, ECDsa key)
|
||||
{
|
||||
var request = new GetRequest
|
||||
{
|
||||
|
@ -168,13 +161,13 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
Removed
|
||||
}
|
||||
|
||||
private async Task WaitForContainer(WaitExpects expect, ContainerID id, PrmWait? waitParams, CallContext ctx)
|
||||
private async Task WaitForContainer(WaitExpects expect, ContainerID id, PrmWait waitParams, CallContext ctx)
|
||||
{
|
||||
var request = GetContainerRequest(id, null, ClientContext.Key.ECDsaKey);
|
||||
var request = GetContainerRequest(id, [], ClientContext.Key.ECDsaKey);
|
||||
|
||||
async Task action()
|
||||
{
|
||||
var response = await service.GetAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await service.GetAsync(request, null, ctx.GetDeadline(), ctx.CancellationToken);
|
||||
Verifier.CheckResponse(response);
|
||||
}
|
||||
|
||||
|
@ -184,9 +177,8 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
private static async Task WaitFor(
|
||||
Func<Task> action,
|
||||
WaitExpects expect,
|
||||
PrmWait? waitParams)
|
||||
PrmWait waitParams)
|
||||
{
|
||||
waitParams ??= PrmWait.DefaultParams;
|
||||
var deadLine = waitParams.GetDeadline();
|
||||
|
||||
while (true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue