Checker implements a Checker by running programs with os.Exec.
| 16 | |
| 17 | // Checker implements a Checker by running programs with os.Exec. |
| 18 | type Checker struct { |
| 19 | // Name is the name of the endpoint. |
| 20 | Name string `json:"name"` |
| 21 | |
| 22 | // Command is the main program entrypoint. |
| 23 | Command string `json:"command"` |
| 24 | |
| 25 | // Arguments are individual program parameters. |
| 26 | Arguments []string `json:"arguments,omitempty"` |
| 27 | |
| 28 | // ThresholdRTT is the maximum round trip time to |
| 29 | // allow for a healthy endpoint. If non-zero and a |
| 30 | // request takes longer than ThresholdRTT, the |
| 31 | // endpoint will be considered unhealthy. Note that |
| 32 | // this duration includes any in-between network |
| 33 | // latency. |
| 34 | ThresholdRTT time.Duration `json:"threshold_rtt,omitempty"` |
| 35 | |
| 36 | // MustContain is a string that the response body |
| 37 | // must contain in order to be considered up. |
| 38 | // NOTE: If set, the entire response body will |
| 39 | // be consumed, which has the potential of using |
| 40 | // lots of memory and slowing down checks if the |
| 41 | // response body is large. |
| 42 | MustContain string `json:"must_contain,omitempty"` |
| 43 | |
| 44 | // MustNotContain is a string that the response |
| 45 | // body must NOT contain in order to be considered |
| 46 | // up. If both MustContain and MustNotContain are |
| 47 | // set, they are and-ed together. NOTE: If set, |
| 48 | // the entire response body will be consumed, which |
| 49 | // has the potential of using lots of memory and |
| 50 | // slowing down checks if the response body is large. |
| 51 | MustNotContain string `json:"must_not_contain,omitempty"` |
| 52 | |
| 53 | // Raise is a string that tells us if we should throw |
| 54 | // a hard error ("error" - the default), or if we should |
| 55 | // just mark something as degraded ("warn" or "warning"). |
| 56 | Raise string `json:"raise,omitempty"` |
| 57 | |
| 58 | // Attempts is how many requests the client will |
| 59 | // make to the endpoint in a single check. |
| 60 | Attempts int `json:"attempts,omitempty"` |
| 61 | |
| 62 | // AttemptSpacing spaces out each attempt in a check |
| 63 | // by this duration to avoid hitting a remote too |
| 64 | // quickly in succession. By default, no waiting |
| 65 | // occurs between attempts. |
| 66 | AttemptSpacing time.Duration `json:"attempt_spacing,omitempty"` |
| 67 | } |
| 68 | |
| 69 | // New creates a new Checker instance based on json config |
| 70 | func New(config json.RawMessage) (Checker, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected