コード例 #1
0
        private async Task UpdateLatestConfig(string name)
        {
            var val = await _provider.GetLatestConfigSetting(name);

            if (val == null)
            {
                _logger.Log(LogLevel.Warning, 0, $"The config {name} was not found in the config service. Skipping...", null, (msg, exc) => msg);
            }
            else
            {
                this.UpdateTarget[name] = new KvpConfig(val);
            }
        }
コード例 #2
0
        public async Task <KvpConfig> GetLatestConfigSetting(string name)
        {
            if (_latestCache.ContainsKey(name))
            {
                var success = _latestCache.TryGetValue(name, out KvpConfig val);
                if (success)
                {
                    return(val);
                }
            }
            var kvpConfig = await _fabricProvider.GetLatestConfigSetting(name);

            if (kvpConfig == null)
            {
                return(kvpConfig);
            }
            var addSuccess = _latestCache.TryAdd(name, new KvpConfig(kvpConfig));

            if (!addSuccess)
            {
                _logger.Log(LogLevel.Warning, 0, "The given config was not added to cache", null, (val, ex) => val);
            }
            return(kvpConfig);
        }