health: aahframe.work/ec/health Index | Files

package health

import "aahframe.work/ec/health"

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

Index

Package Files

health.go version.go

Constants

const Version = "0.1.0"

Version number of library.

type Collector Uses

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 Uses

func NewCollector(interval time.Duration) *Collector

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

func (*Collector) AddReporter Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package health imports 8 packages (graph). Updated 2019-08-02. Refresh now. Tools for package owners.