in pkg/cluster/healthcheck/healthcheck.go [86:128]
func CreateHealthCheck(cluster *model.ClusterConfig, cfg model.HealthCheckConfig) *HealthChecker {
timeout, err := time.ParseDuration(cfg.TimeoutConfig)
if err != nil {
logger.Infof("[health check] timeout parse duration error %s", err)
timeout = DefaultTimeout
}
interval, err := time.ParseDuration(cfg.IntervalConfig)
if err != nil {
logger.Infof("[health check] interval parse duration error %s", err)
interval = DefaultInterval
}
initialDelay, err := time.ParseDuration(cfg.IntervalConfig)
if err != nil {
logger.Infof("[health check] initialDelay parse duration error %s", err)
initialDelay = DefaultFirstInterval
}
unhealthyThreshold := cfg.UnhealthyThreshold
if unhealthyThreshold == 0 {
unhealthyThreshold = DefaultUnhealthyThreshold
}
healthyThreshold := cfg.HealthyThreshold
if healthyThreshold == 0 {
healthyThreshold = DefaultHealthyThreshold
}
hc := &HealthChecker{
protocol: cfg.Protocol,
sessionConfig: cfg.SessionConfig,
cluster: cluster,
timeout: timeout,
intervalBase: interval,
healthyThreshold: healthyThreshold,
unhealthyThreshold: unhealthyThreshold,
initialDelay: initialDelay,
checkers: make(map[string]*EndpointChecker),
}
return hc
}