Documentation
¶
Index ¶
- func NewHandler(os *Status) http.Handler
- type AboutResponse
- type CheckResponse
- type HealthResult
- type Status
- func (s *Status) About() AboutResponse
- func (s *Status) AddChecker(name string, checkerFunc func(cr *CheckResponse)) *Status
- func (s *Status) AddLink(description, url string) *Status
- func (s *Status) AddMetrics(cs ...prometheus.Collector) *Status
- func (s *Status) AddOwner(name, slack string) *Status
- func (s *Status) Check() HealthResult
- func (s *Status) Ready(f func() bool) *Status
- func (s *Status) ReadyAlways() *Status
- func (s *Status) ReadyNever() *Status
- func (s *Status) ReadyNone() *Status
- func (s *Status) ReadyUseHealthCheck() *Status
- func (s *Status) RemoveCheckers(name string) *Status
- func (s *Status) SetRevision(revision string) *Status
- func (s *Status) WithChecksLogger() *Status
- func (s *Status) WithInstrumentedChecks() *Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler created a new HTTP handler that should be mapped to "/__/". It will create all the standard endpoints it can based on how the OpStatus is configured.
Types ¶
type AboutResponse ¶
type AboutResponse struct { Name string `json:"name"` Description string `json:"description"` Owners []ownerResponse `json:"owners"` Links []linkResponse `json:"links,omitempty"` BuildInfo buildInfoResponse `json:"build-info"` }
AboutResponse represents the static "about" information for an application as described in the UW operation endpoints spec. When serialised to JSON it is compiant with that spec.
type CheckResponse ¶
type CheckResponse struct {
// contains filtered or unexported fields
}
CheckResponse is used by a health check function to allow it to indicate the result of the check be calling appropriate methods.
func (*CheckResponse) Degraded ¶
func (cr *CheckResponse) Degraded(output, action string)
Degraded indicates that the check reports degraded health. In addition to the output of the check output, the recommended action should be provided.
func (*CheckResponse) Healthy ¶
func (cr *CheckResponse) Healthy(output string)
Healthy indicates that the check reports good health. The output of the check command should be provided.
func (*CheckResponse) Unhealthy ¶
func (cr *CheckResponse) Unhealthy(output, action, impact string)
Unhealthy indicates an unhealthy check. The output, a recommended action, and a brief description of the impact should be provided.
type HealthResult ¶
type HealthResult struct { Name string `json:"name"` Description string `json:"description"` Health string `json:"health"` CheckResults []healthResultEntry `json:"checks"` }
HealthResult represents the current "health" information for an application as described in the UW operation endpoints spec. When serialised to JSON it is compiant with that spec.
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status represents standard operational information about an application, including how to establish dynamic information such as health or readiness.
func NewStatus ¶
NewStatus returns a new Status, given an application or service name and description.
func (*Status) About ¶
func (s *Status) About() AboutResponse
About returns static information about this application or service.
func (*Status) AddChecker ¶
func (s *Status) AddChecker(name string, checkerFunc func(cr *CheckResponse)) *Status
AddChecker adds a function that can check the applications health. Multiple checkers are allowed. The checker functions should be capable of being called concurrently (with each other and with themselves).
func (*Status) AddLink ¶
AddLink adds a URL link. Multiple are allowed and each should have a brief description.
func (*Status) AddMetrics ¶
func (s *Status) AddMetrics(cs ...prometheus.Collector) *Status
AddMetrics registers prometheus metrics to be exopsed on the /__/metrics endpoint Adding the same metric twice will result in a panic
func (*Status) AddOwner ¶
AddOwner adds an owner entry. Each can have a name, a slack channel or both. Multiple owner entries are allowed.
func (*Status) Check ¶
func (s *Status) Check() HealthResult
Check returns the current health state of the application. Each checker is run concurrently.
func (*Status) ReadyAlways ¶
ReadyAlways indicates that this application is always ready, typically if it has no external systems to depend upon.
func (*Status) ReadyNever ¶
ReadyNever indicates that this application is never ready. Typically this is only useful in testing.
func (*Status) ReadyNone ¶
ReadyNone indicates that this application doesn't expose a concept of readiness.
func (*Status) ReadyUseHealthCheck ¶
ReadyUseHealthCheck indicates that the readiness of this application should re-use the health check. If the health is "ready" or "degraded" the application is considered ready.
func (*Status) RemoveCheckers ¶
RemoveCheckers will remove health check functions added by AddChecker. If multiple checks have been added with the same name, these will all be removed.
func (*Status) SetRevision ¶
SetRevision sets the source control revision string, typically a git hash.
func (*Status) WithChecksLogger ¶
WithChecksLogger enables the outcome of healthchecks to be logged
func (*Status) WithInstrumentedChecks ¶
WithInstrumentedChecks enables the outcome of healthchecks to be instrumented as a counter