Exemplo n.º 1
0
        protected virtual void ComposeAndApplyResult(SignalWrapper <SignalEvent <TKey> > item)
        {
            Stopwatch composeTimer = Stopwatch.StartNew();
            EventHandleResult <SignalDispatch <TKey> > composeResult = ComposeDispatches(item);

            composeTimer.Stop();

            _eventQueue.ApplyResult(item, composeResult.Result);
            _monitor.DispatchesComposed(item.Signal, composeTimer.Elapsed, composeResult.Result, composeResult.Items);
        }
Exemplo n.º 2
0
        protected virtual EventHandleResult <SignalDispatch <TKey> > ComposeDispatches(SignalWrapper <SignalEvent <TKey> > @event)
        {
            //find matching EventHandler
            EventSettings <TKey> eventSettings = _eventSettingsQueries.Select(@event.Signal.EventSettingsId.Value).Result;

            if (eventSettings == null)
            {
                return(EventHandleResult <SignalDispatch <TKey> > .FromResult(ProcessingResult.NoHandlerFound));
            }

            IEventHandler <TKey> eventHandler = _handlerRegistry.MatchHandler(eventSettings.EventHandlerId);

            if (eventHandler == null)
            {
                return(EventHandleResult <SignalDispatch <TKey> > .FromResult(ProcessingResult.NoHandlerFound));
            }

            //compose dispatches for subscribers
            EventHandleResult <SignalDispatch <TKey> > composeResult = eventHandler.ProcessEvent(eventSettings, @event.Signal);

            if (composeResult.Result != ProcessingResult.Success)
            {
                return(composeResult);
            }

            //enqueue dispatches
            _dispatchQueue.Append(composeResult.Items, false);

            @event.IsUpdated = true;
            if (composeResult.IsFinished == false)
            {
                composeResult.Result = ProcessingResult.Repeat;
            }

            return(composeResult);
        }