feat: add slow consumer per-kind tracking with account counters (Gap 5.5)

Adds SlowConsumerTracker class for per-ClientKind slow consumer counting
with configurable threshold callbacks, and extends Account with atomic
IncrementSlowConsumers/SlowConsumerCount/ResetSlowConsumerCount members.
Includes 10 unit tests covering concurrency, threshold firing, and reset.
This commit is contained in:
Joseph Doherty
2026-02-25 11:33:58 -05:00
parent 774717d57c
commit 7e5c6e4fd9
3 changed files with 222 additions and 0 deletions

View File

@@ -152,6 +152,16 @@ public sealed class Account : IDisposable
return true;
}
// Slow consumer tracking
// Go reference: server/client.go — handleSlowConsumer, markConnAsSlow, server/accounts.go slowConsumerCount
private long _slowConsumerCount;
public long SlowConsumerCount => Interlocked.Read(ref _slowConsumerCount);
public void IncrementSlowConsumers() => Interlocked.Increment(ref _slowConsumerCount);
public void ResetSlowConsumerCount() => Interlocked.Exchange(ref _slowConsumerCount, 0L);
// Per-account message/byte stats
private long _inMsgs;
private long _outMsgs;