[#24] Client: Implement pool part1
first iteration - base classes and methods Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
d1271df207
commit
c9a75ea025
72 changed files with 2786 additions and 468 deletions
|
@ -2,62 +2,61 @@
|
|||
|
||||
using Frostfs.V2.Ape;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public struct FrostFsChainTarget(FrostFsTargetType type, string name) : IEquatable<FrostFsChainTarget>
|
||||
{
|
||||
public struct FrostFsChainTarget(FrostFsTargetType type, string name) : IEquatable<FrostFsChainTarget>
|
||||
private ChainTarget? chainTarget;
|
||||
|
||||
public FrostFsTargetType Type { get; } = type;
|
||||
|
||||
public string Name { get; } = name;
|
||||
|
||||
internal ChainTarget GetChainTarget()
|
||||
{
|
||||
private ChainTarget? chainTarget;
|
||||
|
||||
public FrostFsTargetType Type { get; } = type;
|
||||
|
||||
public string Name { get; } = name;
|
||||
|
||||
internal ChainTarget GetChainTarget()
|
||||
return chainTarget ??= new ChainTarget
|
||||
{
|
||||
return chainTarget ??= new ChainTarget
|
||||
{
|
||||
Type = GetTargetType(Type),
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
Type = GetTargetType(Type),
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
|
||||
private static TargetType GetTargetType(FrostFsTargetType type)
|
||||
private static TargetType GetTargetType(FrostFsTargetType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
FrostFsTargetType.Undefined => TargetType.Undefined,
|
||||
FrostFsTargetType.Namespace => TargetType.Namespace,
|
||||
FrostFsTargetType.Container => TargetType.Container,
|
||||
FrostFsTargetType.User => TargetType.User,
|
||||
FrostFsTargetType.Group => TargetType.Group,
|
||||
_ => throw new ArgumentException("Unexpected value for TargetType", nameof(type)),
|
||||
};
|
||||
}
|
||||
FrostFsTargetType.Undefined => TargetType.Undefined,
|
||||
FrostFsTargetType.Namespace => TargetType.Namespace,
|
||||
FrostFsTargetType.Container => TargetType.Container,
|
||||
FrostFsTargetType.User => TargetType.User,
|
||||
FrostFsTargetType.Group => TargetType.Group,
|
||||
_ => throw new ArgumentException("Unexpected value for TargetType", nameof(type)),
|
||||
};
|
||||
}
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
var target = (FrostFsChainTarget)obj;
|
||||
return Equals(target);
|
||||
}
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
var target = (FrostFsChainTarget)obj;
|
||||
return Equals(target);
|
||||
}
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return $"{Name}{Type}".GetHashCode();
|
||||
}
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return $"{Name}{Type}".GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(FrostFsChainTarget left, FrostFsChainTarget right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
public static bool operator ==(FrostFsChainTarget left, FrostFsChainTarget right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(FrostFsChainTarget left, FrostFsChainTarget right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
public static bool operator !=(FrostFsChainTarget left, FrostFsChainTarget right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public readonly bool Equals(FrostFsChainTarget other)
|
||||
{
|
||||
return Type == other.Type && Name.Equals(other.Name, StringComparison.Ordinal);
|
||||
}
|
||||
public readonly bool Equals(FrostFsChainTarget other)
|
||||
{
|
||||
return Type == other.Type && Name.Equals(other.Name, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,41 @@
|
|||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public struct FrostFsChain(byte[] raw) : System.IEquatable<FrostFsChain>
|
||||
{
|
||||
public struct FrostFsChain(byte[] raw) : System.IEquatable<FrostFsChain>
|
||||
private ByteString? grpcRaw;
|
||||
|
||||
public byte[] Raw { get; } = raw;
|
||||
|
||||
internal ByteString GetRaw()
|
||||
{
|
||||
private ByteString? grpcRaw;
|
||||
return grpcRaw ??= ByteString.CopyFrom(Raw);
|
||||
}
|
||||
|
||||
public byte[] Raw { get; } = raw;
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
var chain = (FrostFsChain)obj;
|
||||
return Equals(chain);
|
||||
}
|
||||
|
||||
internal ByteString GetRaw()
|
||||
{
|
||||
return grpcRaw ??= ByteString.CopyFrom(Raw);
|
||||
}
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return Raw.GetHashCode();
|
||||
}
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
var chain = (FrostFsChain)obj;
|
||||
return Equals(chain);
|
||||
}
|
||||
public static bool operator ==(FrostFsChain left, FrostFsChain right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return Raw.GetHashCode();
|
||||
}
|
||||
public static bool operator !=(FrostFsChain left, FrostFsChain right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(FrostFsChain left, FrostFsChain right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(FrostFsChain left, FrostFsChain right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public readonly bool Equals(FrostFsChain other)
|
||||
{
|
||||
return Raw == other.Raw;
|
||||
}
|
||||
public readonly bool Equals(FrostFsChain other)
|
||||
{
|
||||
return Raw == other.Raw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
namespace FrostFS.SDK.ClientV2
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public enum FrostFsTargetType
|
||||
{
|
||||
public enum FrostFsTargetType
|
||||
{
|
||||
Undefined = 0,
|
||||
Namespace,
|
||||
Container,
|
||||
User,
|
||||
Group
|
||||
}
|
||||
Undefined = 0,
|
||||
Namespace,
|
||||
Container,
|
||||
User,
|
||||
Group
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue