[#26] All: Remove V2 from naming
Rename project, namespaces and class names Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
c406df1a78
commit
766f61a5f7
219 changed files with 219 additions and 974 deletions
68
src/FrostFS.SDK.Client/Tools/ClientContext.cs
Normal file
68
src/FrostFS.SDK.Client/Tools/ClientContext.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Grpc.Net.Client;
|
||||
|
||||
namespace FrostFS.SDK.Client;
|
||||
|
||||
public class ClientContext(FrostFSClient client, ECDsa? key, FrostFsOwner? owner, GrpcChannel channel, FrostFsVersion version) : IDisposable
|
||||
{
|
||||
private ArrayPool<byte>? _arrayPool;
|
||||
private string? sessionKey;
|
||||
|
||||
internal FrostFsOwner? Owner { get; } = owner;
|
||||
|
||||
internal string? Address { get; } = channel.Target;
|
||||
|
||||
internal GrpcChannel Channel { get; private set; } = channel;
|
||||
|
||||
internal FrostFsVersion Version { get; } = version;
|
||||
|
||||
internal NetworkSettings? NetworkSettings { get; set; }
|
||||
|
||||
internal FrostFSClient Client { get; } = client;
|
||||
|
||||
internal ClientKey? Key { get; } = key != null ? new ClientKey(key) : null;
|
||||
|
||||
internal SessionCache SessionCache { get; set; }
|
||||
|
||||
internal string? SessionCacheKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sessionKey == null && Key != null && Address != null)
|
||||
{
|
||||
sessionKey = Pool.FormCacheKey(Address, Key.ECDsaKey.PrivateKey().ToString());
|
||||
}
|
||||
|
||||
return sessionKey;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom pool is used for predefined sizes of buffers like grpc chunk
|
||||
/// </summary>
|
||||
internal ArrayPool<byte> GetArrayPool(int size)
|
||||
{
|
||||
_arrayPool ??= ArrayPool<byte>.Create(size, 256);
|
||||
|
||||
return _arrayPool;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Channel?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue