Path: redb-route/redb.Route/Processors/DelayProcessor.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Processors/DelayProcessor.cs
----
using redb.Route.Abstractions;
namespace redb.Route.Processors;
///
/// Delays processing by a specified duration. Supports cancellation.
///
public class DelayProcessor : IProcessor
{
private readonly TimeSpan _delay;
/// Gets the delay duration.
public TimeSpan Delay => _delay;
/// Creates a delay processor with the specified duration.
/// Time to delay before continuing.
public DelayProcessor(TimeSpan delay)
{
if (delay < TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(delay), "Delay must be non-negative.");
_delay = delay;
}
///
public async Task Process(IExchange exchange, CancellationToken ct = default)
{
if (_delay > TimeSpan.Zero)
{
await InflightWaits.DelayAsync(exchange, _delay, ct).ConfigureAwait(false);
}
}
}