feat: add idle heartbeat with pending count headers and flow control stall detection (Gap 3.5)

Heartbeat frames now include Nats-Pending-Messages and Nats-Pending-Bytes
headers populated from the ConsumerHandle. Flow control frames increment
FlowControlPendingCount; AcknowledgeFlowControl() decrements it. IsFlowControlStalled
returns true when pending count reaches MaxFlowControlPending (2).

Go reference: consumer.go:5222 (sendIdleHeartbeat), consumer.go:5495 (sendFlowControl).
This commit is contained in:
Joseph Doherty
2026-02-25 11:05:31 -05:00
parent 0acf59f92a
commit 7611bcc464
3 changed files with 734 additions and 2 deletions

View File

@@ -320,4 +320,11 @@ public sealed record ConsumerHandle(string Stream, ConsumerConfig Config)
public Queue<PushFrame> PushFrames { get; } = new();
public AckProcessor AckProcessor { get; } = new();
public DateTime NextPushDataAvailableAtUtc { get; set; }
/// <summary>
/// Total pending bytes across all unacknowledged messages.
/// Included in idle heartbeat headers as Nats-Pending-Bytes.
/// Go reference: consumer.go sendIdleHeartbeat.
/// </summary>
public long PendingBytes { get; set; }
}