Class OutboxBuilderLeaderElectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Excalibur.LeaderElection.dll
Extension methods for adding leader election gating to IOutboxBuilder.
public static class OutboxBuilderLeaderElectionExtensions
- Inheritance
-
OutboxBuilderLeaderElectionExtensions
- Inherited Members
Methods
WithLeaderElection(IOutboxBuilder)
Configures the outbox background service to skip processing on this instance whenever it does not hold leadership, using the atomic, fencing-token-carrying leadership snapshot rather than an advisory bool.
public static IOutboxBuilder WithLeaderElection(this IOutboxBuilder builder)
Parameters
builderIOutboxBuilderThe outbox builder.
Returns
- IOutboxBuilder
The builder for fluent chaining.
Examples
services.AddExcalibur(x => x.AddOutbox(outbox =>
{
outbox.UseInMemory()
.WithLeaderElection()
.EnableBackgroundProcessing();
}));
Remarks
Registers an ILeaderProcessingGate (also resolvable as IProcessingGate)
backed by the DI-resolved ILeaderElection. The gate fails closed: the current
instance is gated on ILeaderElection.CurrentLeadership is not null, never on the advisory
ILeaderElection.IsLeader bool, so a null leadership snapshot always skips the protected
processing cycle.
This extension requires an ILeaderElection to already be registered in DI (via a
leader-election provider package). Use the
WithLeaderElection(IOutboxBuilder, Func<IServiceProvider, bool>)
overload in Excalibur.Outbox for a custom, non-leader-election gate — a hand-supplied
predicate is advisory only and carries no fencing token.