[#28] Client: Use external GRPC Channnel
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
9bb7b5eff8
commit
c9418a1894
27 changed files with 520 additions and 438 deletions
78
src/FrostFS.SDK.Client/Parameters/PrmObjectClientCutPut.cs
Normal file
78
src/FrostFS.SDK.Client/Parameters/PrmObjectClientCutPut.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
using System.IO;
|
||||
|
||||
namespace FrostFS.SDK.Client;
|
||||
|
||||
public readonly struct PrmObjectClientCutPut(
|
||||
FrostFsObjectHeader? header,
|
||||
Stream? payload,
|
||||
int bufferMaxSize = 0,
|
||||
FrostFsSessionToken? sessionToken = null,
|
||||
byte[]? customBuffer = null,
|
||||
string[]? xheaders = null) : PrmObjectPutBase, System.IEquatable<PrmObjectClientCutPut>
|
||||
{
|
||||
/// <summary>
|
||||
/// Need to provide values like <c>ContainerId</c> and <c>ObjectType</c> to create and object.
|
||||
/// Optional parameters ike <c>Attributes</c> can be provided as well.
|
||||
/// </summary>
|
||||
/// <value>Header with required parameters to create an object</value>
|
||||
public FrostFsObjectHeader? Header { get; } = header;
|
||||
|
||||
/// <summary>
|
||||
/// A stream with source data
|
||||
/// </summary>
|
||||
public Stream? Payload { get; } = payload;
|
||||
|
||||
/// <summary>
|
||||
/// Overrides default size of the buffer for stream transferring.
|
||||
/// </summary>
|
||||
/// <value>Size of the buffer</value>
|
||||
public int BufferMaxSize { get; } = bufferMaxSize;
|
||||
|
||||
/// <summary>
|
||||
/// Allows to define a buffer for chunks to manage by the memory allocation and releasing.
|
||||
/// </summary>
|
||||
public byte[]? CustomBuffer { get; } = customBuffer;
|
||||
|
||||
/// <inheritdoc />
|
||||
public FrostFsSessionToken? SessionToken { get; } = sessionToken;
|
||||
|
||||
/// <summary>
|
||||
/// FrostFS request X-Headers
|
||||
/// </summary>
|
||||
public string[] XHeaders { get; } = xheaders ?? [];
|
||||
|
||||
internal PutObjectContext PutObjectContext { get; } = new();
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || obj is not PrmObjectClientCutPut)
|
||||
return false;
|
||||
|
||||
return Equals((PrmObjectClientCutPut)obj);
|
||||
}
|
||||
|
||||
public readonly bool Equals(PrmObjectClientCutPut other)
|
||||
{
|
||||
return GetHashCode() == other.GetHashCode();
|
||||
}
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return BufferMaxSize
|
||||
^ (Header == null ? 0 : Header.GetHashCode())
|
||||
^ (Payload == null ? 0 : Payload.GetHashCode())
|
||||
^ (CustomBuffer == null ? 0 : CustomBuffer.GetHashCode())
|
||||
^ (SessionToken == null ? 0 : SessionToken.GetHashCode())
|
||||
^ XHeaders.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(PrmObjectClientCutPut left, PrmObjectClientCutPut right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(PrmObjectClientCutPut left, PrmObjectClientCutPut right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
|
@ -1,15 +1,17 @@
|
|||
using System.IO;
|
||||
|
||||
namespace FrostFS.SDK.Client;
|
||||
|
||||
internal interface PrmObjectPutBase : ISessionToken
|
||||
{
|
||||
FrostFsObjectHeader? Header { get; }
|
||||
|
||||
string[] XHeaders { get; }
|
||||
}
|
||||
|
||||
|
||||
public readonly struct PrmObjectPut(
|
||||
FrostFsObjectHeader? header,
|
||||
Stream? payload,
|
||||
bool clientCut,
|
||||
int bufferMaxSize = 0,
|
||||
FrostFsSessionToken? sessionToken = null,
|
||||
byte[]? customBuffer = null,
|
||||
string[]? xheaders = null) : ISessionToken, System.IEquatable<PrmObjectPut>
|
||||
string[]? xheaders = null) : PrmObjectPutBase, System.IEquatable<PrmObjectPut>
|
||||
{
|
||||
/// <summary>
|
||||
/// Need to provide values like <c>ContainerId</c> and <c>ObjectType</c> to create and object.
|
||||
|
@ -18,30 +20,6 @@ public readonly struct PrmObjectPut(
|
|||
/// <value>Header with required parameters to create an object</value>
|
||||
public FrostFsObjectHeader? Header { get; } = header;
|
||||
|
||||
/// <summary>
|
||||
/// A stream with source data
|
||||
/// </summary>
|
||||
public Stream? Payload { get; } = payload;
|
||||
|
||||
/// <summary>
|
||||
/// Object size is limited. In the data exceeds the limit, the object will be splitted.
|
||||
/// If the parameter is <c>true</c>, the client side cut is applied. Otherwise, the data is transferred
|
||||
/// as a stream and will be cut on server side.
|
||||
/// </summary>
|
||||
/// <value>Is client cut is applied</value>
|
||||
public bool ClientCut { get; } = clientCut;
|
||||
|
||||
/// <summary>
|
||||
/// Overrides default size of the buffer for stream transferring.
|
||||
/// </summary>
|
||||
/// <value>Size of the buffer</value>
|
||||
public int BufferMaxSize { get; } = bufferMaxSize;
|
||||
|
||||
/// <summary>
|
||||
/// Allows to define a buffer for chunks to manage by the memory allocation and releasing.
|
||||
/// </summary>
|
||||
public byte[]? CustomBuffer { get; } = customBuffer;
|
||||
|
||||
/// <inheritdoc />
|
||||
public FrostFsSessionToken? SessionToken { get; } = sessionToken;
|
||||
|
||||
|
@ -67,11 +45,7 @@ public readonly struct PrmObjectPut(
|
|||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return BufferMaxSize
|
||||
^ (Header == null ? 0 : Header.GetHashCode())
|
||||
^ (Payload == null ? 0 : Payload.GetHashCode())
|
||||
^ (ClientCut ? 1 : 0)
|
||||
^ (CustomBuffer == null ? 0 : CustomBuffer.GetHashCode())
|
||||
return (Header == null ? 0 : Header.GetHashCode())
|
||||
^ (SessionToken == null ? 0 : SessionToken.GetHashCode())
|
||||
^ XHeaders.GetHashCode();
|
||||
}
|
||||
|
@ -85,4 +59,4 @@ public readonly struct PrmObjectPut(
|
|||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue