Table of Contents

Class DomainEventDispatchReport

Namespace
Trellis.Mediator
Assembly
Trellis.Mediator.dll

The per-handler outcome of a dispatch performed through PublishReportingAsync(IDomainEvent, IReadOnlySet<string>?, CancellationToken).

public sealed class DomainEventDispatchReport
Inheritance
DomainEventDispatchReport
Inherited Members
Extension Methods

Remarks

This is the non-swallowing counterpart to PublishAsync(IDomainEvent, CancellationToken). It exists for callers that own a durable retry mechanism — principally the transactional outbox relay — and therefore need to know which handlers succeeded and which must be retried. Callers without such a mechanism (notably the in-pipeline DomainEventDispatchBehavior<TMessage, TResponse>, which runs post-commit and cannot retry) should keep using IDomainEventPublisher.

Every handler is always attempted: a failing handler never short-circuits its siblings, so one bad handler cannot starve the others of their side effects.

Constructors

DomainEventDispatchReport(IReadOnlyList<string>, IReadOnlyList<DomainEventHandlerFailure>, Exception?)

Initializes a new instance of the DomainEventDispatchReport class.

public DomainEventDispatchReport(IReadOnlyList<string> completedHandlers, IReadOnlyList<DomainEventHandlerFailure> failures, Exception? resolutionFailure)

Parameters

completedHandlers IReadOnlyList<string>

The handlers that are now complete. See CompletedHandlers.

failures IReadOnlyList<DomainEventHandlerFailure>

The handlers that threw during this dispatch.

resolutionFailure Exception

The exception raised while resolving handlers, if any.

Exceptions

ArgumentNullException

Thrown when completedHandlers or failures is null.

Fields

Empty

A report for a dispatch that invoked no handlers and observed no failures.

public static readonly DomainEventDispatchReport Empty

Field Value

DomainEventDispatchReport

Properties

CompletedHandlers

Every handler that is now complete for this event, by HandlerIdentity(Type) — both the ones that succeeded during this dispatch and the ones the caller reported as already complete and that were therefore skipped. The list is cumulative, so a caller persisting it can overwrite its previous value rather than merging.

public IReadOnlyList<string> CompletedHandlers { get; }

Property Value

IReadOnlyList<string>

Failures

The handlers that threw during this dispatch, in invocation order.

public IReadOnlyList<DomainEventHandlerFailure> Failures { get; }

Property Value

IReadOnlyList<DomainEventHandlerFailure>

FirstError

The first error observed, preferring ResolutionFailure, or null when IsComplete. Convenience for callers that record a single error string per attempt.

public Exception? FirstError { get; }

Property Value

Exception

IsComplete

true when handler resolution succeeded and every resolved handler completed — i.e. the event needs no retry.

public bool IsComplete { get; }

Property Value

bool

ResolutionFailure

The exception raised while resolving the event's handlers from the container, or null when resolution succeeded. A resolution failure means no handler ran, so nothing can be marked complete; the whole event must be retried.

public Exception? ResolutionFailure { get; }

Property Value

Exception

Methods

HandlerIdentity(Type)

The stable identity used to name a handler in CompletedHandlers and HandlerType: the declaring assembly's simple name and the type's full name, separated by :.

public static string HandlerIdentity(Type handlerType)

Parameters

handlerType Type

The concrete handler type.

Returns

string

The handler's stable identity.

Remarks

FullName alone is not sufficient: two assemblies can declare distinct handlers with the same namespace-qualified name, and skipping one because the other succeeded would silently drop work. The assembly's simple name is used rather than its fully qualified name so the identity survives a version bump — otherwise a rolling deploy would re-run handlers that had already completed.

Exceptions

ArgumentNullException

Thrown when handlerType is null.