Path: redb-route/redb.Route/Definitions/IdempotentConsumerDefinition.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/Definitions/IdempotentConsumerDefinition.cs ---- using Microsoft.Extensions.Logging; using redb.Route.Abstractions; using redb.Route.Components; using redb.Route.Expressions; using redb.Route.Processors; namespace redb.Route.Definitions; /// /// Scope-opener definition for the Idempotent Consumer EIP. /// When is called, compiles all child /// into an inner pipeline wrapped by an . /// Inherits the leaf DSL from ; /// close the scope with . /// public class IdempotentConsumerDefinition : RouteDefinitionBase, IRouteScope { private readonly IIdempotentRepository? _repository; private readonly string? _repositoryName; private readonly Func _keyExtractor; private readonly bool _skipDuplicate; internal IdempotentConsumerDefinition( IIdempotentRepository repository, Func keyExtractor, bool skipDuplicate = true) { ArgumentNullException.ThrowIfNull(repository); ArgumentNullException.ThrowIfNull(keyExtractor); _repository = repository; _keyExtractor = keyExtractor; _skipDuplicate = skipDuplicate; } internal IdempotentConsumerDefinition( string repositoryName, Func keyExtractor, bool skipDuplicate = true) { ArgumentException.ThrowIfNullOrEmpty(repositoryName); ArgumentNullException.ThrowIfNull(keyExtractor); _repositoryName = repositoryName; _keyExtractor = keyExtractor; _skipDuplicate = skipDuplicate; } /// public override IProcessor CreateProcessor(IRouteContext context) { IProcessor inner = NodePipeline.Body(context, Outputs); var loggerFactory = context.GetService(); var logger = loggerFactory?.CreateLogger(); var repo = _repository ?? context .GetIdempotentRepositoryProvider() .Get(_repositoryName!); return new IdempotentConsumerProcessor(inner, repo, _keyExtractor, _skipDuplicate, logger); } /// Closes this idempotent consumer scope and returns the parent route definition. /// Thrown if no parent route is set. public IRouteDefinition EndIdempotentConsumer() => (IRouteDefinition)(Parent ?? throw new InvalidOperationException( "EndIdempotentConsumer() called without a parent route. Ensure IdempotentConsumer() was called on a route definition.")); /// public IRouteDefinition End() => EndIdempotentConsumer(); }