From 9ae75207fcf135c083ed4c9d7760c376181b4a57 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 22 Feb 2026 23:34:05 -0500 Subject: [PATCH] feat: add ClosedState enum ported from Go client.go --- src/NATS.Server/ClosedState.cs | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/NATS.Server/ClosedState.cs diff --git a/src/NATS.Server/ClosedState.cs b/src/NATS.Server/ClosedState.cs new file mode 100644 index 0000000..40b44a1 --- /dev/null +++ b/src/NATS.Server/ClosedState.cs @@ -0,0 +1,52 @@ +// Ported from Go: server/client.go:188-228 + +namespace NATS.Server; + +/// +/// Reason a client connection was closed. Stored in connection info for monitoring +/// and passed to close handlers during connection teardown. +/// +/// +/// Values start at 1 (matching Go's iota + 1) so that the default zero value +/// is distinct from any valid close reason. +/// +public enum ClosedState +{ + ClientClosed = 1, + AuthenticationTimeout, + AuthenticationViolation, + TLSHandshakeError, + SlowConsumerPendingBytes, + SlowConsumerWriteDeadline, + WriteError, + ReadError, + ParseError, + StaleConnection, + ProtocolViolation, + BadClientProtocolVersion, + WrongPort, + MaxAccountConnectionsExceeded, + MaxConnectionsExceeded, + MaxPayloadExceeded, + MaxControlLineExceeded, + MaxSubscriptionsExceeded, + DuplicateRoute, + RouteRemoved, + ServerShutdown, + AuthenticationExpired, + WrongGateway, + MissingAccount, + Revocation, + InternalClient, + MsgHeaderViolation, + NoRespondersRequiresHeaders, + ClusterNameConflict, + DuplicateRemoteLeafnodeConnection, + DuplicateClientID, + DuplicateServerName, + MinimumVersionRequired, + ClusterNamesIdentical, + Kicked, + ProxyNotTrusted, + ProxyRequired, +}