MCPcopy
hub / github.com/sourcegraph/checkup / Checker

Struct Checker

check/http/http.go:19–73  ·  view source on GitHub ↗

Checker implements a Checker for HTTP endpoints.

Source from the content-addressed store, hash-verified

17
18// Checker implements a Checker for HTTP endpoints.
19type Checker struct {
20 // Name is the name of the endpoint.
21 Name string `json:"endpoint_name"`
22
23 // URL is the URL of the endpoint.
24 URL string `json:"endpoint_url"`
25
26 // UpStatus is the HTTP status code expected by
27 // a healthy endpoint. Default is http.StatusOK.
28 UpStatus int `json:"up_status,omitempty"`
29
30 // ThresholdRTT is the maximum round trip time to
31 // allow for a healthy endpoint. If non-zero and a
32 // request takes longer than ThresholdRTT, the
33 // endpoint will be considered unhealthy. Note that
34 // this duration includes any in-between network
35 // latency.
36 ThresholdRTT time.Duration `json:"threshold_rtt,omitempty"`
37
38 // MustContain is a string that the response body
39 // must contain in order to be considered up.
40 // NOTE: If set, the entire response body will
41 // be consumed, which has the potential of using
42 // lots of memory and slowing down checks if the
43 // response body is large.
44 MustContain string `json:"must_contain,omitempty"`
45
46 // MustNotContain is a string that the response
47 // body must NOT contain in order to be considered
48 // up. If both MustContain and MustNotContain are
49 // set, they are and-ed together. NOTE: If set,
50 // the entire response body will be consumed, which
51 // has the potential of using lots of memory and
52 // slowing down checks if the response body is large.
53 MustNotContain string `json:"must_not_contain,omitempty"`
54
55 // Attempts is how many requests the client will
56 // make to the endpoint in a single check.
57 Attempts int `json:"attempts,omitempty"`
58
59 // AttemptSpacing spaces out each attempt in a check
60 // by this duration to avoid hitting a remote too
61 // quickly in succession. By default, no waiting
62 // occurs between attempts.
63 AttemptSpacing time.Duration `json:"attempt_spacing,omitempty"`
64
65 // Client is the http.Client with which to make
66 // requests. If not set, DefaultHTTPClient is
67 // used.
68 Client *http.Client `json:"-"`
69
70 // Headers contains headers to added to the request
71 // that is sent for the check
72 Headers http.Header `json:"headers,omitempty"`
73}
74
75// New creates a new Checker instance based on json config
76func New(config json.RawMessage) (Checker, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected