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; }
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); } }
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; }
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; }
bool ILocalRepo.RemoveHandler(HandlerInfo handler) { lock (_mutex) return _impl.RemoveHandler(handler); }
void ILocalRepo.AddHandler(HandlerInfo handler) { lock (_mutex) _impl.AddHandler(handler); }
bool ILocalRepo.RemoveHandler(HandlerInfo handler) { bool wasThere = _handlers.Remove(handler); if (wasThere) move_shanpshot_id(); return wasThere; }
void ILocalRepo.AddHandler(HandlerInfo handler) { Validate.NotNull(handler); Validate.NotNull(handler.Topic); Validate.NotNull(handler.Call); move_shanpshot_id(); _handlers.AddLast(handler); }