From 549ec510c822074ac41f98b10cb05004f9745b3c Mon Sep 17 00:00:00 2001 From: Pavel Gross Date: Mon, 12 Aug 2024 10:46:59 +0300 Subject: [PATCH] [#21] Client: Allows multinenant client Using one client for several owners Signed-off-by: Pavel Gross --- src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs | 9 ++------- .../Services/ObjectServiceProvider.cs | 4 ++-- src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs | 8 ++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs index cf68f8d..0fcf91d 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs @@ -1,6 +1,6 @@ -using FrostFS.SDK.ModelsV2; using System.Collections.Specialized; using System.IO; +using FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ClientV2.Parameters; @@ -30,18 +30,13 @@ public sealed class PrmObjectPut : PrmBase, ISessionToken /// Overrides default size of the buffer for stream transferring. /// /// Size of the buffer - public int BufferMaxSize { get; set; } + public int BufferMaxSize { get; set; } /// /// Allows to define a buffer for chunks to manage by the memory allocation and releasing. /// public byte[]? CustomBuffer { get; set; } - /// - /// FrostFS request X-Headers - /// - public NameValueCollection XHeaders { get; set; } = []; - /// public SessionToken? SessionToken { get; set; } diff --git a/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs b/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs index 6901996..603f68a 100644 --- a/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs @@ -331,7 +331,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C while (objectLimitSize == 0 || sentBytes < objectLimitSize) { - // send chanks limited to default or user's settings + // send chunks limited to default or user's settings var bufferSize = objectLimitSize > 0 ? (int)Math.Min(objectLimitSize - sentBytes, chunkSize) : chunkSize; @@ -350,7 +350,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C Chunk = ByteString.CopyFrom(chunkBuffer, 0, bytesCount) } }; - + chunkRequest.Sign(ctx.Key); await stream.Write(chunkRequest); diff --git a/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs b/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs index 2790732..ec06eab 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs @@ -2,15 +2,15 @@ using FrostFS.SDK.ModelsV2; using Grpc.Net.Client; using System; using System.Security.Cryptography; -using System.Buffers; +using FrostFS.SDK.Cryptography; namespace FrostFS.SDK.ClientV2; public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcChannel channel, ModelsV2.Version version) : IDisposable { - private ArrayPool _arrayPool; - - internal OwnerId? Owner { get; } = owner; + private ArrayPool _arrayPool; + + internal OwnerId? Owner { get; } = owner; internal GrpcChannel Channel { get; private set; } = channel;