[#21] Client: Allows multinenant client

Using one client for several owners

Signed-off-by: Pavel Gross <p.gross@yando.com>
This commit is contained in:
Pavel Gross 2024-08-12 10:46:59 +03:00
parent 18126ea763
commit 2a28806ace
30 changed files with 349 additions and 281 deletions

View file

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Threading;
using FrostFS.SDK.ModelsV2;
using FrostFS.SDK.Cryptography;
using Google.Protobuf;
using Grpc.Core.Interceptors;
namespace FrostFS.SDK.ClientV2;
public class Context()
{
private List<Interceptor>? interceptors;
private ByteString publicKeyCache;
public ECDsa Key { get; set; }
public OwnerId OwnerId { get; set; }
public ModelsV2.Version Version { get; set; }
public CancellationToken CancellationToken { get; set; } = default;
public TimeSpan Timeout { get; set; } = default;
public DateTime? Deadline => Timeout.Ticks > 0 ? DateTime.UtcNow.Add(Timeout) : null;
public Action<CallStatistics>? Callback { get; set; }
public List<Interceptor> Interceptors
{
get { return this.interceptors ??= []; }
set { this.interceptors = value; }
}
public ByteString PublicKeyCache
{
get
{
if (publicKeyCache == null)
{
publicKeyCache = ByteString.CopyFrom(Key.PublicKey());
}
return publicKeyCache;
}
}
}