Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker interface {
// Check service health
Check() error
}
Checker interface checks the health of external services (database, external service)
type CheckerResult ¶
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 ¶ added in v0.1.1
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 ¶
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
type Memory ¶
type Memory struct {
// Current statistics
Current MemoryStatus `json:"current"`
// Inital 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 ¶
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 ¶
type Options struct {
// CheckersTimeout is the timeout value when checking the health of registed checkers
CheckersTimeout time.Duration
}
Options of Health instance
type Status ¶
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
Click to show internal directories.
Click to hide internal directories.