private bool msg_shoould_be_sent(Topic topic, RemoteAgent agent, object msg) { var topicFilter = get_topic_filter(topic.Guid, agent); if (topicFilter == null) return true; if (topicFilter.Filters.IsEmpty()) return false; // topic has no listeners on target if (topicFilter.FilterThrows) return true; // there is a local filter but it throws (remote will recalculate filter) try { var filterIsMatched = filter_is_matched(topicFilter.Filters, msg); if (filterIsMatched) return true; } catch (Exception ex) { topicFilter.FilterThrows = true; _log.Warn(ex, "Failed to invoke remote filter for topic {0}", topic.ToJson()); } // no matched filters return false; }
private FilteredTopic get_topic_filter(Guid topicGuid, RemoteAgent agent) { var all = _rrepo.GetFilteredTopics(agent); if (all == null) return null; var query = from filter in all where filter.TopicGuid == topicGuid select filter; return query.FirstOrDefault(); }
private RemoteAgent get_agent(string agentUri) { RemoteAgent agent; if (_remotes.TryGetValue(agentUri, out agent)) return agent; agent = new RemoteAgent { AgentUri = agentUri, SnapshotId = 0, }; _remotes.Add(agentUri, agent); return agent; }
FilteredTopic[] IRemoteRepo.GetFilteredTopics(RemoteAgent agent) { lock (_mutex) return _impl.GetFilteredTopics(agent); }
FilteredTopic[] IRemoteRepo.GetFilteredTopics(RemoteAgent agent) { if (agent.FilteredTopics == null) return null; return agent.FilteredTopics.ToArray(); }