Path: redb-route/redb.Route/Processors/FilterProcessor.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/FilterProcessor.cs ---- using redb.Route.Abstractions; using redb.Route.Predicates; using redb.Route.Telemetry; namespace redb.Route.Processors; /// /// Evaluates a predicate on the exchange and passes through only if true. /// When predicate returns false, the exchange is skipped (no processing). /// /// The predicate is held as an and awaited through /// , so a predicate that has to consult a store or a /// service can do so without blocking. A plain delegate is wrapped in a /// at the boundary. /// /// public class FilterProcessor : IProcessor { private readonly IPredicate _predicate; private readonly IProcessor _next; /// Creates a filter processor from a predicate instance. /// Predicate that must hold for processing to continue. /// The processor to execute when the predicate holds. public FilterProcessor(IPredicate predicate, IProcessor next) { _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); _next = next ?? throw new ArgumentNullException(nameof(next)); } /// Creates a filter processor from a delegate, wrapped as a . /// Predicate that must return true for processing to continue. /// The processor to execute when predicate is true. public FilterProcessor(Func predicate, IProcessor next) : this(new LambdaPredicate(predicate ?? throw new ArgumentNullException(nameof(predicate))), next) { } /// public async Task Process(IExchange exchange, CancellationToken ct = default) { if (await _predicate.MatchesAsync(exchange).ConfigureAwait(false)) { await _next.Process(exchange, ct).ConfigureAwait(false); return; } ProcessorMetrics.FilterDropped.Add(1); } }