NewHealthChecker returns a new health checker configured with the given options.
(hco *options.HealthCheckerOptions)
| 47 | |
| 48 | // NewHealthChecker returns a new health checker configured with the given options. |
| 49 | func NewHealthChecker(hco *options.HealthCheckerOptions) (types.HealthChecker, error) { |
| 50 | hc := &healthChecker{ |
| 51 | component: hco.Component, |
| 52 | enableRepair: hco.EnableRepair, |
| 53 | crictlPath: hco.CriCtlPath, |
| 54 | healthCheckTimeout: hco.HealthCheckTimeout, |
| 55 | coolDownTime: hco.CoolDownTime, |
| 56 | service: hco.Service, |
| 57 | loopBackTime: hco.LoopBackTime, |
| 58 | logPatternsToCheck: hco.LogPatterns.GetLogPatternCountMap(), |
| 59 | } |
| 60 | hc.healthCheckFunc = getHealthCheckFunc(hco) |
| 61 | hc.repairFunc = getRepairFunc(hco) |
| 62 | hc.uptimeFunc = getUptimeFunc(hco.Service) |
| 63 | return hc, nil |
| 64 | } |
| 65 | |
| 66 | // CheckHealth checks for the health of the component and tries to repair if enabled. |
| 67 | // Returns true if healthy, false otherwise. |
no test coverage detected