healthcheck

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Redis     = "redis"
	Memcached = "memcached"
	Web       = "web"
	Custom    = "custom"
	Postgres  = "postgres"
)

Mapped types for IntegrationConfig

View Source
const (
	RedisIntegration       = "Redis DB"
	MemcachedIntegration   = "Memcached DB"
	WebServiceIntegration  = "Web service API"
	CustomizedTestFunction = "Customized test function"
	PostgresIntegration    = "Postgres DB"
)

Mapped typs for kinds of integrations

Variables

This section is empty.

Functions

func CheckCustom

func CheckCustom(config IntegrationConfig, result *ApplicationHealthDetailed, wg *sync.WaitGroup, checklist chan Integration)

Types

type ApplicationConfig

type ApplicationConfig struct {
	Name         string              `json:"name"`
	Version      string              `json:"version"`
	Integrations []IntegrationConfig `json:"integrations"`
}

ApplicationConfig is a config contract to init health caller

type ApplicationHealthDetailed

type ApplicationHealthDetailed struct {
	Name         string        `json:"name,omitempty"`
	Status       bool          `json:"status"`
	Version      string        `json:"version,omitempty"`
	Date         string        `json:"date"`
	Duration     float64       `json:"duration"`
	Integrations []Integration `json:"integrations"`
}

ApplicationHealthDetailed used to check all application integrations and return status of each of then

func HealthCheckerDetailed

func HealthCheckerDetailed(config ApplicationConfig) ApplicationHealthDetailed

HealthCheckerDetailed perform a check for every integration informed

type ApplicationHealthSimple

type ApplicationHealthSimple struct {
	Status string `json:"status"`
}

ApplicationHealthSimple used to simple return a string 'OK'

func HealthCheckerSimple

func HealthCheckerSimple() ApplicationHealthSimple

HealthCheckerSimple performs a simple check of the application

type Auth

type Auth struct {
	User     string
	Password string
}

Auth is a default struct to map user/pass protocol

type HTTPHeader

type HTTPHeader struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"Value,omitempty"`
}

HTTPHeader used to setup webservices integrations

type Integration

type Integration struct {
	Name         string  `json:"name"`
	Kind         string  `json:"kind"`
	Status       bool    `json:"status"`
	ResponseTime float64 `json:"response_time"` //in seconds
	URL          string  `json:"url"`
	Error        string  `json:"error,omitempty"` // error.Error()
}

Integration is the type result for requests

type IntegrationConfig

type IntegrationConfig struct {
	Type    string       `json:"Type"` // must be web | redis | memcache | postgres
	Name    string       `json:"name"`
	Host    string       `json:"host"` // yes you can concat host:port here
	Port    string       `json:"port,omitempty"`
	Headers []HTTPHeader `json:"headers,omitempty"`
	DB      int          `json:"db,omitempty"`      // default value is 0
	TimeOut int          `json:"timeout,omitempty"` // default value: 10
	Auth    Auth         `json:"auth,omitempty"`
	Handle  func() error // custom func validtion
	DBName  string       `json:"dbname,omitempty"`
}

IntegrationConfig used to inform each integration config

Jump to

Keyboard shortcuts

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