Class TaskWhenAllPublisher
- Namespace
- Caesar.NotificationPublishers
- Assembly
- Caesar.dll
Starts every handler immediately and awaits them all. Exceptions from all failing handlers are collected into a single AggregateException so no failure is lost.
public sealed class TaskWhenAllPublisher : INotificationPublisher
- Inheritance
-
TaskWhenAllPublisher
- Implements
- Inherited Members
Remarks
A single failure is rethrown as-is, with its original stack trace. A fault wins over a cancellation; if handlers were only canceled, the publish is canceled.
Each handler is started in turn and runs synchronously until its first await; the rest runs concurrently.
The handlers come from the same scope, so they must not share a scoped service that is not thread-safe, such as an
Entity Framework Core DbContext.
Constructors
TaskWhenAllPublisher()
public TaskWhenAllPublisher()
Methods
Publish(IEnumerable<NotificationHandlerExecutor>, INotification, CancellationToken)
Invokes the handler executors for notification.
public Task Publish(IEnumerable<NotificationHandlerExecutor> handlerExecutors, INotification notification, CancellationToken cancellationToken)
Parameters
handlerExecutorsIEnumerable<NotificationHandlerExecutor>One executor per resolved handler: those for the notification's runtime type, in registration order, then those registered for its base classes and interfaces.
notificationINotificationThe notification being published.
cancellationTokenCancellationTokenCancellation token.