feat: add ClientKind enum with IsInternal extension
This commit is contained in:
22
src/NATS.Server/ClientKind.cs
Normal file
22
src/NATS.Server/ClientKind.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
namespace NATS.Server;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Identifies the type of a client connection.
|
||||||
|
/// Maps to Go's client kind constants in client.go:45-65.
|
||||||
|
/// </summary>
|
||||||
|
public enum ClientKind
|
||||||
|
{
|
||||||
|
Client,
|
||||||
|
Router,
|
||||||
|
Gateway,
|
||||||
|
Leaf,
|
||||||
|
System,
|
||||||
|
JetStream,
|
||||||
|
Account,
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ClientKindExtensions
|
||||||
|
{
|
||||||
|
public static bool IsInternal(this ClientKind kind) =>
|
||||||
|
kind is ClientKind.System or ClientKind.JetStream or ClientKind.Account;
|
||||||
|
}
|
||||||
17
tests/NATS.Server.Tests/InternalClientTests.cs
Normal file
17
tests/NATS.Server.Tests/InternalClientTests.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace NATS.Server.Tests;
|
||||||
|
|
||||||
|
public class InternalClientTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[InlineData(ClientKind.Client, false)]
|
||||||
|
[InlineData(ClientKind.Router, false)]
|
||||||
|
[InlineData(ClientKind.Gateway, false)]
|
||||||
|
[InlineData(ClientKind.Leaf, false)]
|
||||||
|
[InlineData(ClientKind.System, true)]
|
||||||
|
[InlineData(ClientKind.JetStream, true)]
|
||||||
|
[InlineData(ClientKind.Account, true)]
|
||||||
|
public void IsInternal_returns_correct_value(ClientKind kind, bool expected)
|
||||||
|
{
|
||||||
|
kind.IsInternal().ShouldBe(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user