toolbox

package
v0.0.0-...-6a6dcdd Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package toolbox 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{})

more docs: http://beego.me/docs/module/toolbox.md

Index

Constants

This section is empty.

Variables

View Source
var AdminCheckList map[string]HealthChecker

AdminCheckList holds health checker map

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 GetYearDays

func GetYearDays(year int) int

GetYearDays 获取指定年的总天数

func GetYearMonthDays

func GetYearMonthDays(year int, month int) int

GetYearMonthDays 获取指定年、月份的总天数

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

Types

type HealthChecker

type HealthChecker interface {
	Check() error
}

HealthChecker health checker interface

type Statistics

type Statistics struct {
	RequestURL        string
	RequestController string
	RequestNum        int64
	MinTime           time.Duration
	MaxTime           time.Duration
	TotalTime         time.Duration
}

Statistics struct

type URLMap

type URLMap struct {
	LengthLimit int //limit the urlmap's length if it's equal to 0 there's no limit
	// contains filtered or unexported fields
}

URLMap contains several statistics struct to log different data

var StatisticsMap *URLMap

StatisticsMap hosld global statistics data map

func (*URLMap) AddStatistics

func (m *URLMap) AddStatistics(requestMethod, requestURL, requestController string, requesttime time.Duration)

AddStatistics add statistics task. it needs request method, request url, request controller and statistics time duration

func (*URLMap) GetMap

func (m *URLMap) GetMap() map[string]interface{}

GetMap put url statistics result in io.Writer

func (*URLMap) GetMapData

func (m *URLMap) GetMapData() []map[string]interface{}

GetMapData return all mapdata

Jump to

Keyboard shortcuts

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