private ConfigurationQueryResponseType CallService(ConfigurationQueryRequestType request) { // 使用默认的地址 : // http://[env].configuration.colorstudio.com.cn var result = client.Call <ConfigurationQueryRequestType, ConfigurationQueryResponseType> ($"{GetConfigurationServerUri()}/api/configuration/query", request, DEFAULT_TIMEOUT_IN_MS, serailzer); return(result.Result); }
private void Sync(string file) { var request = new ConfigurationQueryRequestType() { CurrentVersion = version, File = file }; logger.Info($"Fetch configuration, file : {version}, version : {file}"); var response = CallService(request); if (response.Header.ResponseCode == (int)ErrorCode.ConfigurationNotChanged) { logger.Info("Configuration file has not been changed"); return; } if (response.Header.ResponseCode != (int)ErrorCode.Success) { throw new SoaServiceException(ErrorCode.InvalidConfigurationFile, $"Error to fetch configuration file : {response.Header.Remark}"); } version = response.Version; logger.Info($"Fetch configuration file successfully, new version : {version}"); if (response.Properties == null || response.Properties.Count == 0) { properties.Clear(); return; } var dic = new ConcurrentDictionary <string, string>(); foreach (var property in response.Properties) { dic.TryAdd(property.Key, property.Value); } properties = dic; // 执行事件监听的动作 foreach (var action in listeners) { action.Invoke(); } }