Anarchy.Toolkit.Core.Events
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Core · Package catalog
In-process publish/subscribe and building blocks for a generic domain-event pipeline.
dotnet add package Anarchy.Toolkit.Core.Events
- Implement
ILocalEventandILocalEventHandler<T>and register the local bus withservices.AddLocalEventBus(). - Build domain-event processing around
EventEnvelopeBase,DomainEventEnvelope,PersistedDomainEvent,DomainEventProcessorBase<T>,DomainEventHandlerDispatcher<T>andEventEnvelopeParser. Types live in theEnvelopes,DomainandLocalnamespaces. - The local bus is in-process; use a message-broker implementation for external delivery.
When to use it
Use the local bus to notify other components within the same process, or use the domain-event types to build an event processing pipeline. The local bus is not a durable queue: events are lost if the process stops, and it does not deliver across service instances.
How to use it
Register AppTelemetry and the bus, then register each handler explicitly. For example, with an application-defined OrderPlaced : ILocalEvent and OrderPlacedHandler : ILocalEventHandler<OrderPlaced>:
using Anarchy.Toolkit.Core.Events.Extension.Microsoft.DependencyInjection;
using Anarchy.Toolkit.Core.Events.Local;
using Anarchy.Toolkit.Core.Telemetry;
using Microsoft.Extensions.DependencyInjection;
services.AddCoreTelemetry();
services.AddLocalEventBus();
services.AddScoped<ILocalEventHandler<OrderPlaced>, OrderPlacedHandler>();
// In a service that receives ILocalEventBus via DI:
await bus.PublishAsync(new OrderPlaced(), absorbErrors: false, ct: cancellationToken);
Each publish resolves handlers in a new DI scope and awaits them sequentially. Handler exceptions are logged and absorbed by default; set absorbErrors: false to propagate the first failure. No registered handlers is a no-op. For external delivery, compose this package with a broker adapter instead.
See the toolkit overview and architecture guide.
Releases
See the release notes for the complete release history.