health

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 8 Imported by: 0

README

Health Check Collector by aah framework

Build Status Version GoDoc

News

Usage

# go.mod
require aahframe.work/ec/health v0.1.0

Visit official website https://aahframework.org to learn more about aah framework.

Contributors

Have a look, here.

Issues

Please report issues at https://aahframework.org/issues.

License

Released under MIT License.

Documentation

Overview

Package health provides and easy way of checking dependencies for your aah application

Index

Constants

View Source
const Version = "0.1.0"

Version number of library.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

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

Collector contains the health reporters to check and its responded data for the JSON response.

func NewCollector

func NewCollector(interval time.Duration) *Collector

NewCollector method returns a `Collector` instance. It periodically checks all its registered reporters.

func (*Collector) AddReporter

func (c *Collector) AddReporter(config *Config) error

AddReporter method adds a dependency to health check reporter that will be called per interval to get health report.

func (*Collector) Register

func (c *Collector) Register(app *aah.Application, basePath ...string) error

Register method registers the health collector into aah application with two routes `/healthcheck` and `/ping`.

Provides optional base path or route prefix for the above routes.

func (*Collector) RegisterForDomain

func (c *Collector) RegisterForDomain(app *aah.Application, domainName string, basePath ...string) error

RegisterForDomain method registers the health collector into aah application with two routes `/healthcheck` and `/ping` for given domain hostname.

Provides optional base path or route prefix for the above routes.

type Config

type Config struct {
	Name     string
	Reporter Reporter
	SoftFail bool // if true it will allow errors so won't report unhealthy
}

Config struct contains a Reporter configuration

type Reporter

type Reporter interface {
	// Check will return nil if dependency is reachable/healthy
	// You should implement this func with a sensible timeout (< 3 or 5 sec)
	Check() error
}

Reporter interface for a dependency that can be health-checked.

Jump to

Keyboard shortcuts

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