feat: add consumer reset to specific sequence (Gap 3.12)

Add ResetToSequence to ConsumerManager that updates NextSequence,
clears AckProcessor state via new ClearAll(), and zeroes PendingBytes.
Add AckProcessor.SetAckFloor() that prunes pending entries below the
new floor. Go reference: consumer.go:4241 processResetReq.
This commit is contained in:
Joseph Doherty
2026-02-25 11:15:33 -05:00
parent b9aa62ae99
commit 778687cf6f
3 changed files with 292 additions and 0 deletions

View File

@@ -225,6 +225,28 @@ public sealed class ConsumerManager : IDisposable
return true;
}
/// <summary>
/// Resets a consumer's position to the specified sequence.
/// Clears pending acks and redelivery state.
/// Go reference: consumer.go:4241 processResetReq.
/// </summary>
public bool ResetToSequence(string stream, string durableName, ulong sequence)
{
if (!_consumers.TryGetValue((stream, durableName), out var handle))
return false;
// Update the consumer's next sequence
handle.NextSequence = sequence;
// Clear pending acks — all outstanding acks are invalid after reset
handle.AckProcessor.ClearAll();
// Clear pending bytes
handle.PendingBytes = 0;
return true;
}
public bool Unpin(string stream, string durableName)
{
return _consumers.ContainsKey((stream, durableName));