コード例 #1
0
        private readonly ConcurrentDictionary <string, ApolloNotificationMessages> _remoteNotificationMessages; //namespaceName -> watchedKey -> notificationId

        public RemoteConfigLongPollService(ConfigServiceLocator serviceLocator, HttpUtil httpUtil, IApolloOptions configUtil)
        {
            _serviceLocator = serviceLocator;
            _httpUtil       = httpUtil;
            _options        = configUtil;
            _longPollFailSchedulePolicyInSecond = new ExponentialSchedulePolicy(1, 120);    //in second
            _longPollSuccessSchedulePolicyInMs  = new ExponentialSchedulePolicy(100, 1000); //in millisecond
            _longPollNamespaces         = new ConcurrentDictionary <string, ISet <RemoteConfigRepository> >();
            _notifications              = new ConcurrentDictionary <string, long?>();
            _remoteNotificationMessages = new ConcurrentDictionary <string, ApolloNotificationMessages>();
        }
コード例 #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();
 }
コード例 #3
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);
        }
コード例 #4
0
        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)));
        }