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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user