healthcheck

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

healthcheck check the provided checks.

Usage

// register checks
registrar := healthcheck.NewRegistrar()
registrar.RegisterAsyncCheck(10*time.Second, 5*time.Second, healthcheck.Check{
		Name: "dummy",
		Check: func(ctx context.Context) error {
			// error make this check fail, nil will make it succeed
			return nil
		},
})
ck := registrar.BuildChecker(simple_checker.New())

// start all checks
ck.Start()

// get check result
ck.Check(ctx)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistrar

func NewRegistrar(logger log.Logger) *registrar

Types

type Check

type Check struct {
	Name    string
	Check   func(ctx context.Context) error
	Timeout time.Duration

	UpdateInterval time.Duration
	InitialDelay   time.Duration
}

Check represent a health check

type Checker

type Checker interface {
	Start()
	Stop()
	Check(ctx context.Context) Result
	Build([]Check)
}

type Registrar

type Registrar interface {
	// RegisterCheck(check Check)   // register a sync check
	RegisterAsyncCheck(refreshPeriod time.Duration, initialDelay time.Duration, check Check)
	BuildChecker(checker Checker) Checker
}

Registrar supports check registration and checker creation.

type Result

type Result struct {
	Status string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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