op

package
v0.0.0-...-e7d65e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 10 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(os *Status) http.Handler

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

func NewStatus(name, description string) *Status

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 (s *Status) AddLink(description, url string) *Status

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

func (s *Status) AddOwner(name, slack string) *Status

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) Ready

func (s *Status) Ready(f func() bool) *Status

Ready allows specifying any readiness function.

func (*Status) ReadyAlways

func (s *Status) ReadyAlways() *Status

ReadyAlways indicates that this application is always ready, typically if it has no external systems to depend upon.

func (*Status) ReadyNever

func (s *Status) ReadyNever() *Status

ReadyNever indicates that this application is never ready. Typically this is only useful in testing.

func (*Status) ReadyNone

func (s *Status) ReadyNone() *Status

ReadyNone indicates that this application doesn't expose a concept of readiness.

func (*Status) ReadyUseHealthCheck

func (s *Status) ReadyUseHealthCheck() *Status

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

func (s *Status) RemoveCheckers(name string) *Status

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

func (s *Status) SetRevision(revision string) *Status

SetRevision sets the source control revision string, typically a git hash.

func (*Status) WithChecksLogger

func (s *Status) WithChecksLogger() *Status

WithChecksLogger enables the outcome of healthchecks to be logged

func (*Status) WithInstrumentedChecks

func (s *Status) WithInstrumentedChecks() *Status

WithInstrumentedChecks enables the outcome of healthchecks to be instrumented as a counter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL