[#1] Add presentation layer

Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
Ivan Pchelintsev 2024-05-13 17:27:32 +03:00
parent 2800fff041
commit bb6e187b61
22 changed files with 778 additions and 79 deletions

View file

@ -1,31 +1,37 @@
using System.Security.Cryptography;
using FrostFS.Container;
using FrostFS.Netmap;
using FrostFS.Object;
using FrostFS.SDK.ClientV2.Mappers.GRPC;
using FrostFS.SDK.Cryptography;
using FrostFS.SDK.ModelsV2;
using FrostFS.Session;
using Grpc.Core;
using Grpc.Net.Client;
using Version = FrostFS.SDK.ModelsV2.Version;
namespace FrostFS.SDK.ClientV2;
public partial class Client
public partial class Client: IFrostFSClient
{
private readonly ECDsa _key;
private GrpcChannel _channel;
private Version _version = new (2, 13);
private readonly ECDsa _key;
private readonly OwnerId _owner;
public readonly ModelsV2.Version Version = new (2, 13);
private ContainerService.ContainerServiceClient _containerServiceClient;
private NetmapService.NetmapServiceClient _netmapServiceClient;
private ObjectService.ObjectServiceClient _objectServiceClient;
private SessionService.SessionServiceClient _sessionServiceClient;
public Client(string key, string host)
{
// TODO: Развязать клиент и реализацию GRPC
_key = key.LoadWif();
_owner = OwnerId.FromKey(_key);
InitGrpcChannel(host);
InitContainerClient();
InitNetmapClient();
InitObjectClient();
InitSessionClient();
CheckFrostFsVersionSupport();
}
@ -33,11 +39,8 @@ public partial class Client
private void CheckFrostFsVersionSupport()
{
var localNodeInfo = GetLocalNodeInfoAsync().Result;
var frostFsVersion = new Version(
(int)localNodeInfo.Body.Version.Major,
(int)localNodeInfo.Body.Version.Minor
);
if (!frostFsVersion.IsSupported(_version))
var frostFsVersion = localNodeInfo.Body.Version.ToModel();
if (!frostFsVersion.IsSupported(Version))
{
var msg = $"FrostFS {frostFsVersion} is not supported.";
Console.WriteLine(msg);
@ -86,6 +89,11 @@ public partial class Client
{
_netmapServiceClient = new NetmapService.NetmapServiceClient(_channel);
}
private void InitObjectClient()
{
_objectServiceClient = new ObjectService.ObjectServiceClient(_channel);
}
private void InitSessionClient()
{