[#24] Client: Implement pool part2
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
c9a75ea025
commit
ee20798379
63 changed files with 801 additions and 526 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -12,7 +13,7 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
{
|
||||
private readonly NetmapService.NetmapServiceClient netmapServiceClient;
|
||||
|
||||
internal NetmapServiceProvider(NetmapService.NetmapServiceClient netmapServiceClient, EnvironmentContext context)
|
||||
internal NetmapServiceProvider(NetmapService.NetmapServiceClient netmapServiceClient, ClientContext context)
|
||||
: base(context)
|
||||
{
|
||||
this.netmapServiceClient = netmapServiceClient;
|
||||
|
@ -20,8 +21,8 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
|
||||
internal async Task<NetworkSettings> GetNetworkSettingsAsync(CallContext ctx)
|
||||
{
|
||||
if (EnvironmentContext.NetworkSettings != null)
|
||||
return EnvironmentContext.NetworkSettings;
|
||||
if (ClientContext.NetworkSettings != null)
|
||||
return ClientContext.NetworkSettings;
|
||||
|
||||
var response = await GetNetworkInfoAsync(ctx).ConfigureAwait(false);
|
||||
|
||||
|
@ -38,7 +39,7 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
SetNetworksParam(param, settings);
|
||||
}
|
||||
|
||||
EnvironmentContext.NetworkSettings = settings;
|
||||
ClientContext.NetworkSettings = settings;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
@ -46,10 +47,10 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
internal async Task<FrostFsNodeInfo> GetLocalNodeInfoAsync(PrmNodeInfo args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
ctx.Key ??= EnvironmentContext.Key?.ECDsaKey;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new InvalidObjectException(nameof(ctx.Key));
|
||||
throw new ArgumentNullException(nameof(args), "Key is null");
|
||||
|
||||
var request = new LocalNodeInfoRequest
|
||||
{
|
||||
|
@ -59,8 +60,6 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(ctx.Key);
|
||||
|
||||
|
||||
|
||||
var response = await netmapServiceClient.LocalNodeInfoAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
@ -70,10 +69,10 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
|
||||
internal async Task<NetworkInfoResponse> GetNetworkInfoAsync(CallContext ctx)
|
||||
{
|
||||
ctx.Key ??= EnvironmentContext.Key?.ECDsaKey;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new InvalidObjectException(nameof(ctx.Key));
|
||||
throw new ArgumentNullException(nameof(ctx), "Key is null");
|
||||
|
||||
var request = new NetworkInfoRequest();
|
||||
|
||||
|
@ -91,10 +90,10 @@ internal sealed class NetmapServiceProvider : ContextAccessor
|
|||
internal async Task<FrostFsNetmapSnapshot> GetNetmapSnapshotAsync(PrmNetmapSnapshot args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
ctx.Key ??= EnvironmentContext.Key?.ECDsaKey;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new InvalidObjectException(nameof(ctx.Key));
|
||||
throw new ArgumentNullException(nameof(args), "Key is null");
|
||||
|
||||
var request = new NetmapSnapshotRequest();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue