private async Task <ServiceCommandDescriptor> GetServiceCommand(string path) { ServiceCommandDescriptor result = null; var client = await GetConsulClient(); var watcher = new NodeMonitorWatcher(GetConsulClient, _manager, path, (oldData, newData) => NodeChange(oldData, newData), tmpPath => { var index = tmpPath.LastIndexOf("/"); return(_serviceHeartbeatManager.ExistsWhitelist(tmpPath.Substring(index + 1))); }); var queryResult = await client.KV.Keys(path); if (queryResult.Response != null) { var data = await client.GetDataAsync(path); if (data != null) { watcher.SetCurrentData(data); result = GetServiceCommand(data); } } return(result); }
private async Task <MqttServiceRoute> GetRoute(string path) { MqttServiceRoute result = null; var watcher = new NodeMonitorWatcher(_consul, _manager, path, async(oldData, newData) => await NodeChange(oldData, newData), tmpPath => { var index = tmpPath.LastIndexOf("/"); return(_serviceHeartbeatManager.ExistsWhitelist(tmpPath.Substring(index + 1))); }); var queryResult = await _consul.KV.Keys(path); if (queryResult.Response != null) { var data = (await _consul.GetDataAsync(path)); if (data != null) { watcher.SetCurrentData(data); result = await GetRoute(data); } } return(result); }