go-health: github.com/Talento90/go-health Index | Files

package health

import "github.com/Talento90/go-health"

Index

Package Files

health.go memory.go

type Checker Uses

type Checker interface {
    // Check service health
    Check() error
}

Checker interface checks the health of external services (database, external service)

type CheckerResult Uses

type CheckerResult struct {

    // Status (CHECKED/TIMEOUT)
    Status string `json:"status"`
    // Error
    Error error `json:"error,omitempty"`
    // ResponseTime
    ResponseTime string `json:"response_time"`
    // contains filtered or unexported fields
}

CheckerResult struct represent the result of a checker

type DiffMemoryStatus Uses

type DiffMemoryStatus struct {
    // TotalAlloc is cumulative bytes allocated for heap objects.
    TotalAlloc int64 `json:"total_alloc"`
    // HeapAlloc is bytes of allocated heap objects.
    HeapAlloc int64 `json:"heap_alloc"`
    // ResidentSetSize is bytes of heap memory obtained from the OS.
    ResidentSetSize int64 `json:"rss"`
}

DiffMemoryStatus contains memory statistics

type Health Uses

type Health interface {
    // GetStatus return the current status of the service
    GetStatus() *Status
    // RegisterChecker register a service to check their health
    RegisterChecker(name string, check Checker)
    // ServeHTTP handler for http services
    ServeHTTP(w http.ResponseWriter, r *http.Request)
    // Shutdown set isShutdown flag meaning the service is shutting down
    Shutdown()
}

Health interface

func New Uses

func New(name string, opt Options) Health

New returns a new Health

type Memory Uses

type Memory struct {
    // Current statistics
    Current MemoryStatus `json:"current"`
    // Initial statistics when Health was created
    Initial MemoryStatus `json:"initial"`
    // Diff statistics between Current - Initial
    Diff DiffMemoryStatus `json:"diff"`
}

Memory contains the current, initial and difference statistics

type MemoryStatus Uses

type MemoryStatus struct {
    // TotalAlloc is cumulative bytes allocated for heap objects.
    TotalAlloc uint64 `json:"total_alloc"`
    // HeapAlloc is bytes of allocated heap objects.
    HeapAlloc uint64 `json:"heap_alloc"`
    // ResidentSetSize is bytes of heap memory obtained from the OS.
    ResidentSetSize uint64 `json:"rss"`
}

MemoryStatus contains memory statistics

type Options Uses

type Options struct {
    // CheckersTimeout is the timeout value when checking the health of registered checkers
    CheckersTimeout time.Duration
}

Options of Health instance

type Status Uses

type Status struct {
    // Service name
    Service string `json:"service"`
    // Uptime of the service (How long service is running)
    Uptime string `json:"up_time"`
    // StartTime
    StartTime string `json:"start_time"`
    // Memory statistics
    Memory Memory `json:"memory"`
    // GoRoutines being used
    GoRoutines int `json:"go_routines"`
    // IsShuttingDown is active
    IsShuttingDown bool `json:"is_shutting_down"`
    // HealthCheckers status
    HealthCheckers map[string]CheckerResult `json:"health_checkers"`
}

Status of the service

Package health imports 5 packages (graph). Updated 2018-06-22. Refresh now. Tools for package owners.