public Task AddListenerAsync(AddListenerRequest request) { if (request == null) { throw new NacosException(ConstValue.CLIENT_INVALID_PARAM, "request param invalid"); } if (string.IsNullOrWhiteSpace(request.Tenant)) { request.Tenant = _options.Namespace; } if (string.IsNullOrWhiteSpace(request.Group)) { request.Group = ConstValue.DefaultGroup; } request.CheckParam(); var name = BuildName(request.Tenant, request.Group, request.DataId); if (listeners.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) { _logger.LogWarning($"[add-listener] error, {name} has been added."); return(Task.CompletedTask); } Timer timer = new Timer( async x => { await PollingAsync(x); #if !DEBUG }, request, 0, _options.ListenInterval); #else }, request, 0, 8000);
public Task AddListenerAsync(AddListenerRequest request) { if (request == null) { throw new NacosException(NacosException.CLIENT_INVALID_PARAM, "request param invalid"); } if (string.IsNullOrWhiteSpace(request.Tenant)) { request.Tenant = _options.Namespace; } if (string.IsNullOrWhiteSpace(request.Group)) { request.Group = ConstValue.DefaultGroup; } request.CheckParam(); var name = BuildName(request.Tenant, request.Group, request.DataId); if (listeners.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) { _logger?.LogWarning($"[add-listener] error, {name} has been added."); return(Task.CompletedTask); } var cts = new CancellationTokenSource(); _ = PollingAsync(request, cts.Token); listeners.Add(new Listener(name, cts)); return(Task.CompletedTask); }