/// <inheritdoc/> public void EventHandlerCompletedForEvent(CorrelationId correlationId, EventHandlerId eventHandlerId, Type type) { _logger.Debug("Event Handler {EventHandler} completed for Event {EventType} with correlation {CorrelationId}", eventHandlerId, type, correlationId); if (_eventHandlersWaitersByScope.ContainsKey(correlationId)) { var waiter = _eventHandlersWaitersByScope[correlationId]; waiter.Signal(new EventHandlerType(eventHandlerId, type)); if (waiter.IsDone()) { _eventHandlersWaitersByScope.TryRemove(correlationId, out EventHandlersWaiter _); } } }
/// <inheritdoc/> public void RegisterHandler(EventHandlerId eventHandler, IEnumerable <Type> eventTypes) { eventTypes.ForEach(_ => { var eventHandlerType = new EventHandlerType(eventHandler, _); _eventHandlersByEventType.AddOrUpdate(_, new List <EventHandlerType> { eventHandlerType }, (_, v) => { v.Add(eventHandlerType); return(v); }); }); }
void ThrowIfIllegalId(EventHandlerId id) { var stream = new StreamId { Value = id }; }
/// <inheritdoc/> public Task Register <TEventType>(EventHandlerId id, ScopeId scope, bool partitioned, IEventHandler <TEventType> handler, CancellationToken cancellationToken = default) where TEventType : IEvent { _completion.RegisterHandler(id, handler.HandledEventTypes); return(_processors.GetFor(id, scope, partitioned, handler).RegisterAndHandleForeverWithPolicy(_policy, cancellationToken)); }
/// <summary> /// Initializes a new instance of the <see cref="EventHandlerType"/> class. /// </summary> /// <param name="handler">The <see cref="EventHandlerId" />.</param> /// <param name="type">The <see cref="Type" /> of the event handler.</param> public EventHandlerType(EventHandlerId handler, Type type) { EventHandler = handler; Type = type; }