checkup: github.com/sourcegraph/checkup Index | Files | Directories

package checkup

import "github.com/sourcegraph/checkup"

Package checkup provides means for checking and reporting the status and performance of various endpoints in a distributed, lock-free, self-hosted fashion.

Index

Package Files

check.go checkup.go errors.go interfaces.go notifier.go storage.go

Variables

var DefaultConcurrentChecks = 5

DefaultConcurrentChecks is how many checks, at most, to perform concurrently.

type Checker Uses

type Checker interface {
    Type() string
    Check() (types.Result, error)
}

Checker can create a types.Result.

type Checkup Uses

type Checkup struct {
    // Checkers is the list of Checkers to use with
    // which to perform checks.
    Checkers []Checker `json:"checkers,omitempty"`

    // ConcurrentChecks is how many checks, at most, to
    // perform concurrently. Default is
    // DefaultConcurrentChecks.
    ConcurrentChecks int `json:"concurrent_checks,omitempty"`

    // Timestamp is the timestamp to force for all checks.
    // Useful if wanting to perform distributed check
    // "at the same time" even if they might actually
    // be a few milliseconds or seconds apart.
    Timestamp time.Time `json:"timestamp,omitempty"`

    // Storage is the storage mechanism for saving the
    // results of checks. Required if calling Store().
    // If Storage is also a Maintainer, its Maintain()
    // method will be called by c.CheckAndStore().
    Storage Storage `json:"storage,omitempty"`

    // Notifiers are list of notifiers to invoke with
    // the results after checks from all checkers have
    // completed. Notifier may evaluate and choose to
    // send a notification of potential problems.
    Notifiers []Notifier `json:"notifiers,omitempty"`
}

Checkup performs a routine checkup on endpoints or services.

func (Checkup) Check Uses

func (c Checkup) Check() ([]types.Result, error)

Check performs the health checks. An error is only returned in the case of a misconfiguration or if any one of the Checkers returns an error.

func (Checkup) CheckAndStore Uses

func (c Checkup) CheckAndStore() error

CheckAndStore performs health checks and immediately stores the results to the configured storage if there were no errors. Checks are not performed if c.Storage is nil. If c.Storage is also a Maintainer, Maintain() will be called if Store() is successful.

func (Checkup) CheckAndStoreEvery Uses

func (c Checkup) CheckAndStoreEvery(interval time.Duration) *time.Ticker

CheckAndStoreEvery calls CheckAndStore every interval. It returns the ticker that it's using so you can stop it when you don't want it to run anymore. This function does NOT block (it runs the ticker in a goroutine). Any errors are written to the standard logger. It would not be wise to set an interval lower than the time it takes to perform the checks.

func (Checkup) MarshalJSON Uses

func (c Checkup) MarshalJSON() ([]byte, error)

MarshalJSON marshals c into JSON with type information included on the interface values.

func (*Checkup) UnmarshalJSON Uses

func (c *Checkup) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshales b into c. To succeed, it requires type information for the interface values.

type Maintainer Uses

type Maintainer interface {
    Maintain() error
}

Maintainer can maintain a store of results by deleting old check files that are no longer needed or performing other required tasks.

type Notifier Uses

type Notifier interface {
    Type() string
    Notify([]types.Result) error
}

Notifier can notify ops or sysadmins of potential problems. A Notifier should keep state to avoid sending repeated notices more often than the admin would like.

type Provisioner Uses

type Provisioner interface {
    Provision() (types.ProvisionInfo, error)
}

Provisioner is a type of storage mechanism that can provision itself for use with checkup. Provisioning need only happen once and is merely a convenience so that the user can get up and running with their status page more quickly. Presumably, the info returned from Provision should be used on the status page side of things ot access the check files (like a key pair that is used for read-only access).

type Storage Uses

type Storage interface {
    Type() string
    Store([]types.Result) error
}

Storage can store results.

type StorageReader Uses

type StorageReader interface {
    // Fetch returns the contents of a check file.
    Fetch(checkFile string) ([]types.Result, error)
    // GetIndex returns the storage index, as a map where keys are check
    // result filenames and values are the associated check timestamps.
    GetIndex() (map[string]int64, error)
}

StorageReader can read results from the Storage.

Directories

PathSynopsis
check/dns
check/exec
check/http
check/tcp
check/tls
cmd
cmd/checkup
notifier/discord
notifier/mail
notifier/mailgun
notifier/pushover
notifier/slack
storage/appinsights
storage/fs
storage/github
storage/mysql
storage/postgres
storage/s3
storage/sql
storage/sqlite3
types

Package checkup imports 25 packages (graph) and is imported by 15 packages. Updated 2020-07-21. Refresh now. Tools for package owners.