public ApolloConfigurationProvider(string?sectionKey, IConfigRepository configRepository)
 {
     SectionKey       = sectionKey;
     ConfigRepository = configRepository;
     ConfigRepository.AddChangeListener(this);
     _initializeTask = ConfigRepository.Initialize();
 }
        public override void Load()
        {
            _initializeTask.ConfigureAwait(false).GetAwaiter().GetResult();

            _configRepository.AddChangeListener(this);

            SetData(_configRepository.GetConfig());
        }
 public override void SetUpstreamRepository(IConfigRepository upstreamConfigRepository)
 {
     if (upstreamConfigRepository == null)
     {
         return;
     }
     //clear previous listener
     if (m_upstream != null)
     {
         m_upstream.RemoveChangeListener(this);
     }
     m_upstream = upstreamConfigRepository;
     TrySyncFromUpstream();
     upstreamConfigRepository.AddChangeListener(this);
 }
Esempio n. 4
0
 private void Initialize()
 {
     try
     {
         _configProperties.WriteFullFence(_configRepository.GetConfig());
     }
     catch (Exception ex)
     {
         Logger.Warn($"Init Apollo Local Config failed - namespace: {_namespace}", ex);
     }
     finally
     {
         //register the change listener no matter config repository is working or not
         //so that whenever config repository is recovered, config could get changed
         _configRepository.AddChangeListener(this);
     }
 }
Esempio n. 5
0
        public async Task Initialize()
        {
            await _configRepository.Initialize().ConfigureAwait(false);

            try
            {
                _configProperties = _configRepository.GetConfig();
            }
            catch (Exception ex)
            {
                Logger().Warn($"Init Apollo Local Config failed - namespace: {_namespace}", ex);
            }
            finally
            {
                //register the change listener no matter config repository is working or not
                //so that whenever config repository is recovered, config could get changed
                _configRepository.AddChangeListener(this);
            }
        }
Esempio n. 6
0
 private void Initialize()
 {
     try
     {
         m_configProperties.WriteFullFence(m_configRepository.GetConfig());
     }
     catch (Exception ex)
     {
         logger.Warn(
             string.Format("Init Apollo Local Config failed - namespace: {0}, reason: {1}.",
                           m_namespace, ExceptionUtil.GetDetailMessage(ex)));
     }
     finally
     {
         //register the change listener no matter config repository is working or not
         //so that whenever config repository is recovered, config could get changed
         m_configRepository.AddChangeListener(this);
     }
 }
        private void Sync()
        {
            if (_upstream != null)
            {
                _upstream.AddChangeListener(this);

                //sync with upstream immediately
                if (TrySyncFromUpstream())
                {
                    return;
                }
            }

            try
            {
                _fileProperties = LoadFromLocalCacheFile(_baseDir, Namespace);
            }
            catch (Exception ex)
            {
                Logger.Warn(ex);
            }
        }
        public override async Task Initialize()
        {
            if (_upstream != null)
            {
                await _upstream.Initialize().ConfigureAwait(false);

                _upstream.AddChangeListener(this);

                //sync with upstream immediately
                if (TrySyncFromUpstream())
                {
                    return;
                }
            }

            try
            {
                _fileProperties = LoadFromLocalCacheFile(_baseDir, Namespace);
            }
            catch (Exception ex)
            {
                Logger().Warn(ex);
            }
        }
Esempio n. 9
0
        public override void Load()
        {
            _configRepository.AddChangeListener(this);

            SetData(_configRepository.GetConfig());
        }