Example #1
0
        bool ILocalDispatcher.DispatchRemoteMsg(object msg, HandlerInfo[] handlers)
        {
            var hasListeners = dispatch_to_handlers(msg, handlers);
            Interlocked.Increment(ref _counters.RemoteMsgs);

            if (hasListeners)
                Interlocked.Increment(ref _counters.RemoteMsgsDispatched);

            return hasListeners;
        }
Example #2
0
 private void dispatch_msg(HandlerInfo handler, object msg)
 {
     try
     {
         handler.Call(msg);
         Interlocked.Increment(ref _counters.HandlersCalled);
     }
     catch (Exception ex)
     {
         _log.Warn(ex, "Failed to dispatch local message; topic='{0}'", handler.Topic.Name);
         Interlocked.Increment(ref _counters.HandlersFailed);
     }
 }
Example #3
0
        private bool msg_should_be_filtered(HandlerInfo handler, object msg)
        {
            if (handler.Filter == null)
                return false;

            var shouldBeFiltered = false;

            try
            {
                var filterIsMatched = handler.Filter(msg);
                shouldBeFiltered = !filterIsMatched;
            }
            catch
            {
                Interlocked.Increment(ref _counters.FiltersFailed);
            }

            return shouldBeFiltered;
        }
Example #4
0
        private bool dispatch_to_handlers(object msg, HandlerInfo[] handlers)
        {
            if (handlers.IsEmpty())
                return false;

            var hasListeners = false;

            foreach (var handler in handlers)
            {
                if (msg_should_be_filtered(handler, msg))
                {
                    Interlocked.Increment(ref _counters.HandlersFiltered);
                    continue;
                }

                hasListeners = true;
                dispatch_msg(handler, msg);
            }

            return hasListeners;
        }
Example #5
0
 bool ILocalRepo.RemoveHandler(HandlerInfo handler)
 {
     lock (_mutex) return _impl.RemoveHandler(handler);
 }
Example #6
0
 void ILocalRepo.AddHandler(HandlerInfo handler)
 {
     lock (_mutex) _impl.AddHandler(handler);
 }
Example #7
0
        bool ILocalRepo.RemoveHandler(HandlerInfo handler)
        {
            bool wasThere = _handlers.Remove(handler);

            if (wasThere)
                move_shanpshot_id();

            return wasThere;
        }
Example #8
0
        void ILocalRepo.AddHandler(HandlerInfo handler)
        {
            Validate.NotNull(handler);
            Validate.NotNull(handler.Topic);
            Validate.NotNull(handler.Call);

            move_shanpshot_id();

            _handlers.AddLast(handler);
        }