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:
@@ -294,6 +294,32 @@ public sealed class AckProcessor
|
||||
_pending.Remove(sequence);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all pending acks, terminated set, and resets the ack floor.
|
||||
/// Used during consumer reset to specific sequence.
|
||||
/// Go reference: consumer.go processResetReq — clear all tracking state.
|
||||
/// </summary>
|
||||
public void ClearAll()
|
||||
{
|
||||
_pending.Clear();
|
||||
_terminated.Clear();
|
||||
AckFloor = 0;
|
||||
TerminatedCount = 0;
|
||||
_exceededSequences.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the ack floor to the specified value.
|
||||
/// Used during consumer reset.
|
||||
/// </summary>
|
||||
public void SetAckFloor(ulong floor)
|
||||
{
|
||||
AckFloor = floor;
|
||||
// Remove any pending entries below or at the new floor
|
||||
foreach (var key in _pending.Keys.Where(k => k <= floor).ToArray())
|
||||
_pending.Remove(key);
|
||||
}
|
||||
|
||||
public bool HasPending => _pending.Count > 0;
|
||||
public int PendingCount => _pending.Count;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user