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>();
    }
    public async Task ConfigServerTest()
    {
        var moq = new Mock <IApolloOptions>();

        moq.SetupGet(o => o.ConfigServer).Returns(new[] { "http://106.54.227.205:8080/" });

        var options = moq.Object;

        var locator = new ConfigServiceLocator(new HttpUtil(options), options);

        var services = await locator.GetConfigServices().ConfigureAwait(false);

        Assert.Equal(1, services.Count);
        Assert.Equal(options.ConfigServer.FirstOrDefault(), services[0].HomepageUrl);
    }
Ejemplo n.º 3
0
        public async Task MetaServerTest()
        {
            var moq = new Mock <IApolloOptions>();

            moq.SetupGet(o => o.AppId).Returns("apollo-client");
            moq.SetupGet(o => o.MetaServer).Returns("http://106.54.227.205:8080/");
            moq.SetupGet(o => o.ConfigServer).Returns(new string[0]);

            var options = moq.Object;

            var locator = new ConfigServiceLocator(new HttpUtil(options), options);

            var services = await locator.GetConfigServices().ConfigureAwait(false);

            Assert.Equal(1, services.Count);
            Assert.Equal(options.MetaServer, services[0].HomepageUrl);
        }
Ejemplo n.º 4
0
 public ConfigService()
 {
     ConfigServer = ConfigServiceLocator.GetService();
 }