示例#1
0
        public RemoteConfigRepository(string @namespace,
                                      IApolloOptions configUtil,
                                      HttpUtil httpUtil,
                                      ConfigServiceLocator serviceLocator,
                                      RemoteConfigLongPollService remoteConfigLongPollService) : base(@namespace)
        {
            _options        = configUtil;
            _httpUtil       = httpUtil;
            _serviceLocator = serviceLocator;
            _remoteConfigLongPollService = remoteConfigLongPollService;

            _timer = new Timer(SchedulePeriodicRefresh);
        }
示例#2
0
 public RemoteConfigRepository(string namespaceName)
 {
     m_namespace      = namespaceName;
     m_configCache    = new ThreadSafe.AtomicReference <ApolloConfig>(null);
     m_configUtil     = ComponentLocator.Lookup <ConfigUtil>();
     m_httpUtil       = ComponentLocator.Lookup <HttpUtil>();
     m_serviceLocator = ComponentLocator.Lookup <ConfigServiceLocator>();
     m_remoteConfigLongPollService = ComponentLocator.Lookup <RemoteConfigLongPollService>();
     m_longPollServiceDto          = new ThreadSafe.AtomicReference <ServiceDTO>(null);
     this.TrySync();
     this.SchedulePeriodicRefresh();
     this.ScheduleLongPollingRefresh();
 }
        private IConfigRepository CreateConfigRepository(string @namespace)
        {
            if (Env.Local.Equals(_options.Env))
            {
                Console.WriteLine("==== Apollo is in local mode! Won\'t pull configs from remote server! ====");
                return(new LocalFileConfigRepository(@namespace, _options));
            }

            var locator     = new ConfigServiceLocator(_httpUtil, _options);
            var pollService = new RemoteConfigLongPollService(locator, _httpUtil, _options);

            return(new LocalFileConfigRepository(@namespace, _options, new RemoteConfigRepository(@namespace, _options, _httpUtil, locator, pollService)));
        }