admin

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package admin healthcheck

type DatabaseCheck struct { }

func (dc *DatabaseCheck) Check() error {
	if dc.isConnected() {
		return nil
	} else {
		return errors.New("can't connect database")
	 }
}

AddHealthCheck("database",&DatabaseCheck{})

Index

Constants

This section is empty.

Variables

View Source
var AdminCheckList map[string]HealthChecker

AdminCheckList holds health checker map

View Source
var CommandNotFound = errors.New("Command not found")

Functions

func AddHealthCheck

func AddHealthCheck(name string, hc HealthChecker)

AddHealthCheck add health checker with name string

func GetCPUProfile

func GetCPUProfile(w io.Writer)

GetCPUProfile start cpu profile monitor

func MemProf

func MemProf(w io.Writer)

MemProf record memory profile in pprof

func PrintGCSummary

func PrintGCSummary(w io.Writer)

PrintGCSummary print gc information to io.Writer

func ProcessInput

func ProcessInput(input string, w io.Writer)

ProcessInput parse input command string

func RegisterCommand

func RegisterCommand(module string, commandName string, command Command)

RegisterCommand is not thread-safe do not use it in concurrent case

Types

type Command

type Command interface {
	Execute(params ...interface{}) *Result
}

Command is an experimental interface We try to use this to decouple modules All other modules depends on this, and they register the command they support We may change the API in the future, so be careful about this.

func GetCommand

func GetCommand(module string, cmdName string) Command

type HealthChecker

type HealthChecker interface {
	Check() error
}

HealthChecker health checker interface

type Result

type Result struct {
	// Status is the same as http.Status
	Status  int
	Error   error
	Content interface{}
}

func (*Result) IsSuccess

func (r *Result) IsSuccess() bool

Jump to

Keyboard shortcuts

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