[#28] Client: Apply code optimizations
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
766f61a5f7
commit
749000a090
57 changed files with 845 additions and 1116 deletions
|
@ -1,19 +1,16 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using Grpc.Core.Interceptors;
|
||||
using Grpc.Net.Client;
|
||||
|
||||
namespace FrostFS.SDK.Client;
|
||||
|
||||
public class ClientContext(FrostFSClient client, ECDsa? key, FrostFsOwner? owner, GrpcChannel channel, FrostFsVersion version) : IDisposable
|
||||
public class ClientContext(FrostFSClient client, ClientKey key, FrostFsOwner owner, GrpcChannel channel, FrostFsVersion version) : IDisposable
|
||||
{
|
||||
private ArrayPool<byte>? _arrayPool;
|
||||
private string? sessionKey;
|
||||
|
||||
internal FrostFsOwner? Owner { get; } = owner;
|
||||
internal FrostFsOwner Owner { get; } = owner;
|
||||
|
||||
internal string? Address { get; } = channel.Target;
|
||||
|
||||
|
@ -25,9 +22,16 @@ public class ClientContext(FrostFSClient client, ECDsa? key, FrostFsOwner? owner
|
|||
|
||||
internal FrostFSClient Client { get; } = client;
|
||||
|
||||
internal ClientKey? Key { get; } = key != null ? new ClientKey(key) : null;
|
||||
internal ClientKey Key { get; } = key;
|
||||
|
||||
internal SessionCache? SessionCache { get; set; }
|
||||
|
||||
internal Action<CallStatistics>? Callback { get; set; }
|
||||
|
||||
internal Collection<Interceptor>? Interceptors { get; set; }
|
||||
|
||||
internal Action<Exception>? PoolErrorHandler { get; set; }
|
||||
|
||||
internal SessionCache SessionCache { get; set; }
|
||||
|
||||
internal string? SessionCacheKey
|
||||
{
|
||||
|
@ -35,23 +39,13 @@ public class ClientContext(FrostFSClient client, ECDsa? key, FrostFsOwner? owner
|
|||
{
|
||||
if (sessionKey == null && Key != null && Address != null)
|
||||
{
|
||||
sessionKey = Pool.FormCacheKey(Address, Key.ECDsaKey.PrivateKey().ToString());
|
||||
sessionKey = Pool.FormCacheKey(Address, Key.PublicKey);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue