/// <summary>
        /// Registers a delegate to run as a service health check
        /// </summary>
        /// <param name="healthCheckDelegate"></param>
        /// <param name="intervalInSeconds"></param>
        /// <param name="deregisterIfCriticalAfterInMinutes"></param>
        public HostHealthCheck(HealthCheckDelegate healthCheckDelegate, int intervalInSeconds = 60, int?deregisterIfCriticalAfterInMinutes = null)
        {
            healthCheckDelegate.ThrowIfNull(nameof(healthCheckDelegate));

            HealthCheckDelegate = healthCheckDelegate;
            IntervalInSeconds   = intervalInSeconds;
            DeregisterIfCriticalAfterInMinutes = deregisterIfCriticalAfterInMinutes;
        }
        /// <summary>
        /// Registers a delegate to run as a service health check
        /// </summary>
        /// <param name="healthCheckDelegate"></param>
        /// <param name="intervalInSeconds"></param>
        /// <param name="deregisterIfCriticalAfterInMinutes"></param>
        public HostHealthCheck(HealthCheckDelegate healthCheckDelegate, int intervalInSeconds = 60, int? deregisterIfCriticalAfterInMinutes = null)
        {
            healthCheckDelegate.ThrowIfNull(nameof(healthCheckDelegate));

            HealthCheckDelegate = healthCheckDelegate;
            IntervalInSeconds = intervalInSeconds;
            DeregisterIfCriticalAfterInMinutes = deregisterIfCriticalAfterInMinutes;
        }
Exemple #3
0
        public IHealthCheckBuilder Register(
            string name,
            HealthCheckDelegate healthCheck,
            HealthStatus failureStatus = HealthStatus.Unhealthy,
            IEnumerable <string> tags  = null,
            TimeSpan?timeout           = null)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidOperationException("Please provide a name for this health check");
            }

            var registration = new HealthCheckRegistration(name, _ => new DelegatingHealthCheck(healthCheck), failureStatus, tags, timeout);

            _healthCheckRegistrations.Add(registration);

            return(this);
        }
Exemple #4
0
 /// <summary>
 /// Add a service health check based on a delegate
 /// </summary>
 /// <param name="check">a delegate to represent a service health check</param>
 /// <param name="intervalInSeconds">the timed interval for running this check in seconds</param>
 /// <param name="deregisterIfCriticalAfterInMinutes">Instructs consul to deregister the service if the service check is failing after x minutes</param>
 public void AddServiceCheck(HealthCheckDelegate check, int intervalInSeconds = 60, int?deregisterIfCriticalAfterInMinutes = null)
 {
     healthCheck = new HostHealthCheck(check, intervalInSeconds, deregisterIfCriticalAfterInMinutes);
 }
 public DelegatingHealthCheck(HealthCheckDelegate healthCheck)
 {
     _healthCheck = healthCheck ?? throw new ArgumentNullException();
 }