healthcheck

package
v0.0.0-...-2b9378c Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package health check provides to add echo instance. Example: ``` package main import (

"github.com/labstack/echo/v4"
"github.com/labstack/echo-contrib/healthcheck"

)

func main() {
    e := echo.New()
	opts:=[]healthcheck.Option{
		healthcheck.WithTimeout(5*time.Second),
		healthcheck.WithChecker("call",healthcheck.HttpChecker("https://www.google.com",200,0,nil)),
		healthcheck.WithObserver("call",healthcheck.TcpChecker("127.0.0.1",5*time.Second)),
		healthcheck.WithObserver("fileX",healthcheck.FileChecker("abc")),
	}
	h:=healthcheck.New(opts...).SetEndpoint("status")
	h.Use(e)
    e.Logger.Fatal(e.Start(":1323"))
}

``` Check the status: ``` curl -X GET http://localhost:5000/status ```

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMaxCheckTimeExceededError = errors.New("max check time exceeded")
)

Functions

This section is empty.

Types

type Checker

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

func CheckMongoDb

func CheckMongoDb(db *mongo.Database) Checker

type CheckerFunc

type CheckerFunc func(ctx context.Context) error

func FileChecker

func FileChecker(f string) CheckerFunc

func HttpChecker

func HttpChecker(url string, statusCode int, timeout time.Duration, headers http.Header) CheckerFunc

func TcpChecker

func TcpChecker(addr string, timeout time.Duration) CheckerFunc

func (CheckerFunc) Check

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

type Health

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

func New

func New(opts ...Option) *Health

func (*Health) SetEndpoint

func (h *Health) SetEndpoint(statusEndpoint string) *Health

func (*Health) Use

func (h *Health) Use(e *echo.Echo)

type Option

type Option func(*Health)

func WithChecker

func WithChecker(name string, s Checker) Option

func WithObserver

func WithObserver(name string, s Checker) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

Jump to

Keyboard shortcuts

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