health

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Check(ctx context.Context) error
}

Checker checks the status of the dependency and returns error. In case the dependency is working as expected, return nil.

type CheckerFunc

type CheckerFunc func(ctx context.Context) error

CheckerFunc is a convenience type to create functions that implement the Checker interface.

func (CheckerFunc) Check

func (c CheckerFunc) Check(ctx context.Context) error

Check Implements the Checker interface to allow for any func() error method to be passed as a Checker

type Health

type Health struct {
	// contains filtered or unexported fields
}

func NewHealth

func NewHealth(opts ...Option) *Health

Handler returns an http.Handler

func (*Health) RegisterChecker

func (h *Health) RegisterChecker(name string, s Checker)

func (*Health) RegisterObserver

func (h *Health) RegisterObserver(name string, s Checker)

func (*Health) ServeHTTP

func (h *Health) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Option

type Option func(*Health)

Option adds optional parameter for the Health

func WithChecker

func WithChecker(name string, s Checker) Option

WithChecker adds a status checker that needs to be added as part of healthcheck. i.e database, cache or any external dependency

func WithObserver

func WithObserver(name string, s Checker) Option

WithObserver adds a status checker but it does not fail the entire status.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures the global timeout for all individual checkers.

type Response

type Response struct {
	Status string            `json:"status,omitempty"`
	Errors map[string]string `json:"errors,omitempty"`
}

Jump to

Keyboard shortcuts

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