types

package
v0.0.0-...-f9ad26b Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableColor

func DisableColor()

DisableColor disables ANSI colors in the Result default string.

func Timestamp

func Timestamp() int64

Timestamp returns the UTC Unix timestamp in nanoseconds.

Types

type Attempt

type Attempt struct {
	RTT   time.Duration `json:"rtt"`
	Error string        `json:"error,omitempty"`
}

Attempt is an attempt to communicate with the endpoint.

type Attempts

type Attempts []Attempt

Attempts is a list of Attempt that can be sorted by RTT.

func (Attempts) Len

func (a Attempts) Len() int

func (Attempts) Less

func (a Attempts) Less(i, j int) bool

func (Attempts) Swap

func (a Attempts) Swap(i, j int)

type Errors

type Errors []error

Errors is an error type that concatenates multiple errors.

func (Errors) Empty

func (e Errors) Empty() bool

Empty returns whether e has any non-nil errors in it.

func (Errors) Error

func (e Errors) Error() string

Error returns a string containing all the errors in e.

type ProvisionInfo

type ProvisionInfo struct {
	// The ID of a user that was created for accessing checks.
	UserID string `json:"user_id"`

	// The username of a user that was created for accessing checks.
	Username string `json:"username"`

	// The ID or name of the ID/key used to access checks. Expect
	// this value to be made public. (It should have read-only
	// access to the checks.)
	PublicAccessKeyID string `json:"public_access_key_id"`

	// The "secret" associated with the PublicAccessKeyID, but
	// expect this value to be made public. (It should provide
	// read-only access to the checks.)
	PublicAccessKey string `json:"public_access_key"`
}

ProvisionInfo contains the results of provisioning a new storage facility for check files. Its values should be used by the status page in order to obtain read-only access to the check files.

func (ProvisionInfo) String

func (i ProvisionInfo) String() string

String returns the information in i in a human-readable format along with an important notice.

type Result

type Result struct {
	// Title is the title (or name) of the thing that was checked.
	// It should be unique, as it acts like an identifier to users.
	Title string `json:"title,omitempty"`

	// Endpoint is the URL/address/path/identifier/locator/whatever
	// of what was checked.
	Endpoint string `json:"endpoint,omitempty"`

	// Timestamp is when the check occurred; UTC UnixNano format.
	Timestamp int64 `json:"timestamp,omitempty"`

	// Times is a list of each individual check attempt.
	Times Attempts `json:"times,omitempty"`

	// ThresholdRTT is the maximum RTT that was tolerated before
	// considering performance to be degraded. Leave 0 if irrelevant.
	ThresholdRTT time.Duration `json:"threshold,omitempty"`

	// Healthy, Degraded, and Down contain the ultimate conclusion
	// about the endpoint. Exactly one of these should be true;
	// any more or less is a bug.
	Healthy  bool `json:"healthy,omitempty"`
	Degraded bool `json:"degraded,omitempty"`
	Down     bool `json:"down,omitempty"`

	// Notice contains a description of some condition of this
	// check that might have affected the result in some way.
	// For example, that the median RTT is above the threshold.
	Notice string `json:"notice,omitempty"`

	// Message is an optional message to show on the status page.
	// For example, what you're doing to fix a problem.
	Message string `json:"message,omitempty"`
}

Result is the result of a health check.

func NewResult

func NewResult() Result

func (Result) ComputeStats

func (r Result) ComputeStats() Stats

ComputeStats computes basic statistics about r.

func (Result) Status

func (r Result) Status() StatusText

Status returns a text representation of the overall status indicated in r.

func (Result) String

func (r Result) String() string

String returns a human-readable rendering of r.

type Stats

type Stats struct {
	Total  time.Duration `json:"total,omitempty"`
	Mean   time.Duration `json:"mean,omitempty"`
	Median time.Duration `json:"median,omitempty"`
	Min    time.Duration `json:"min,omitempty"`
	Max    time.Duration `json:"max,omitempty"`
}

Stats is a type that holds information about a Result, especially its various Attempts.

type StatusText

type StatusText string

StatusText is the textual representation of the result of a status check.

const (
	StatusHealthy  StatusText = "healthy"
	StatusDegraded StatusText = "degraded"
	StatusDown     StatusText = "down"
	StatusUnknown  StatusText = "unknown"
)

Text representations for the status of a check.

func (StatusText) PriorityOver

func (s StatusText) PriorityOver(other StatusText) bool

PriorityOver returns whether s has priority over other. For example, a Down status has priority over Degraded.

Jump to

Keyboard shortcuts

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