Exemplo n.º 1
0
        public static TweekManagementRulesDriver StartNew(HttpGet getter, TweekManagementRulesDriverSettings settings, ILogger logger = null,
                                                          IMeasureMetrics metrics = null, IScheduler scheduler = null)
        {
            var driver = new TweekManagementRulesDriver(getter, settings, logger,
                                                        metrics, scheduler);

            driver.Start();
            return(driver);
        }
Exemplo n.º 2
0
        public void Configure(IServiceCollection services, IConfiguration configuration)
        {
            var managementServiceUrl = new Uri(configuration.GetValue <string>("Rules:Management:Url"));
            var httpClient           = new HttpClient
            {
                BaseAddress = managementServiceUrl
            };
            var settings = new TweekManagementRulesDriverSettings
            {
                SampleIntervalInMs = configuration.GetValue("Rules:Management:SampleIntervalInMs", 30000),
                FailureDelayInMs   = configuration.GetValue("Rules:Management:FailureDelayInMs", 60000)
            };

            services.AddSingleton <IRulesDriver>(
                ctx =>
                TweekManagementRulesDriver.StartNew(httpClient.GetAsync, settings, ctx.GetService <ILoggerFactory>().CreateLogger("RulesManagementDriver"),
                                                    ctx.GetService <IMeasureMetrics>()));
        }
Exemplo n.º 3
0
        public void Configure(IServiceCollection services, IConfiguration configuration)
        {
            var managementServiceUrl = new Uri(configuration.GetValue <string>("Rules:Management:Url"));
            var httpClient           = new HttpClient()
            {
                BaseAddress = managementServiceUrl
            };
            var settings = new TweekManagementRulesDriverSettings();

            configuration.GetValue <string>("Rules:Management:SampleIntervalInMs")?.Iter(x => settings.SampleIntervalInMs = x);
            configuration.GetValue <string>("Rules:Management:FailureDelayInMs")?.Iter(x => settings.FailureDelayInMs     = x);

            services.AddSingleton <IRulesDriver>(
                ctx =>
                TweekManagementRulesDriver.StartNew(httpClient.GetAsync, settings, ctx.GetService <ILoggerFactory>().CreateLogger("RulesManagementDriver"),
                                                    ctx.GetService <IMeasureMetrics>()));

            services.AddSingleton <IDiagnosticsProvider>(ctx => new TweekManagementHealthCheck(ctx.GetServices <IRulesDriver>().OfType <TweekManagementRulesDriver>().Single()));
        }
 public TweekManagementHealthCheck(TweekManagementRulesDriver driver)
 {
     _driver = driver;
 }