/// <summary> /// 移除监听 /// </summary> public void RemoveListener(Action <string> listener) { if (listener == null) { throw new ArgumentNullException(nameof(listener)); } var wrap = new ManagerListenerWrap(listener, MD5); if (_listeners.Remove(wrap)) { _logger.Info($"[{_name}] [remove-listener] ok, dataId={DataId}, group={Group}, cnt={_listeners.Count}"); } }
/// <summary> /// 添加监听 /// </summary> public void AddListener(Action <string> listener) { if (listener == null) { throw new ArgumentNullException(nameof(listener)); } var wrap = new ManagerListenerWrap(listener, MD5); if (_listeners.AddIfNotExist(wrap)) { _logger.Info($"[{_name}] [add-listener] ok, tenant={Tenant}, dataId={DataId}, group={Group}, cnt={_listeners.Count}"); } }
private void SafeNotifyListener(string dataId, string group, string content, string md5, ManagerListenerWrap listenerWrap) { // 此处为异步,当前为同步实现 ConfigResponse cr = new ConfigResponse(); cr.DataId = DataId; cr.Group = group; cr.Content = content; _configFilterChainManager.DoFilter(null, cr); listenerWrap.Listener(cr.Content); listenerWrap.LastCallMD5 = md5; _logger.Info($"[{_name}] [notify-ok] dataId={dataId}, group={group}, md5={md5}"); }