Example #1
0
        public HealthCheckHostedService(ILogger <HealthCheckHostedService> logger, HealthCheckServiceConfiguration config, IMemoryCache cache, IConfiguration configuration, ICheckFactory factory, BuildModel build) : base(logger, config.Enabled, config.Interval, true)
        {
            config.Name = factory.ExpandTemplate(config.Name);
            checks      = new List <Check>();
            foreach (var check in config.Checks)
            {
                checks.Add(factory.Create(check));
            }

            var healthCheck = new HealthCheck(config, checks, build, cache, factory.Logger, factory.Recorder);

            healthCheck.Initialize(new CheckConfiguration()
            {
                Name = config.Name, Interval = config.Interval, CacheDuration = config.CacheDuration, Timeout = config.Interval
            });
            checks.Add(healthCheck);

            this.config = config;
        }