Class InflightDrainGuard

Namespace: redb.Route.Core
Assembly: redb.Route.dll

Encapsulates inflight tracking and drain-on-stop logic.
Used by both poll-based () and callback-based consumers
(RabbitMQ, MQTT, AMQP, TCP) to avoid duplicating CTS lifecycle + drain + force-cancel boilerplate.

public sealed class InflightDrainGuard : IDisposable

Inheritance

Object→InflightDrainGuard

Implements

Properties

DrainTimeout

Drain timeout for graceful stop (default 30s).

public TimeSpan DrainTimeout { get; set; }

InflightCount

Current number of in-flight exchanges.

public int InflightCount { get; }

ProcessingToken

The processing cancellation token. Valid after .

public CancellationToken ProcessingToken { get; }

Methods

Decrement()

Decrements the inflight counter.

public void Decrement()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

DrainAsync(CancellationToken, ILogger?, string?)

Drains in-flight exchanges and force-cancels if drain times out.

public Task DrainAsync(CancellationToken ct, ILogger? logger = null, string? consumerName = null)

Increment()

Increments the inflight counter. Must be paired with .

public void Increment()

Start(CancellationToken)

Initializes the processing CTS linked to the application shutdown token.

public void Start(CancellationToken ct = default)