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://asana.me/docs/module/toolbox.md
Index ¶
- Variables
- func AddHealthCheck(name string, hc HealthChecker)
- func AddTask(taskName string, t Tasker)
- func DeleteTask(taskName string)
- func GetCPUProfile(w io.Writer)
- func MemProf(w io.Writer)
- func PrintGCSummary(w io.Writer)
- func ProcessInput(input string, w io.Writer)
- func StartTask()
- func StopTask()
- type HealthChecker
- type MapSorter
- type Schedule
- type Statistics
- type Task
- type TaskFunc
- type Tasker
- type URLMap
Constants ¶
This section is empty.
Variables ¶
var AdminCheckList map[string]HealthChecker
AdminCheckList holds health checker map
var (
AdminTaskList map[string]Tasker
)
The bounds for each field.
Functions ¶
func AddHealthCheck ¶
func AddHealthCheck(name string, hc HealthChecker)
AddHealthCheck add health checker with name string
func PrintGCSummary ¶
PrintGCSummary print gc information to io.Writer
func ProcessInput ¶
ProcessInput parse input command string
Types ¶
type HealthChecker ¶
type HealthChecker interface {
Check() error
}
HealthChecker health checker interface
type MapSorter ¶
MapSorter sort map for tasker
func NewMapSorter ¶
NewMapSorter create new tasker map
type Schedule ¶
type Schedule struct { Second uint64 Minute uint64 Hour uint64 Day uint64 Month uint64 Week uint64 }
Schedule time taks schedule
type Statistics ¶
type Statistics struct { RequestURL string RequestController string RequestNum int64 MinTime time.Duration MaxTime time.Duration TotalTime time.Duration }
Statistics struct
type Task ¶
type Task struct { TaskName string Spec *Schedule SpecStr string DoFunc TaskFunc Prev time.Time Next time.Time ErrList []*taskerr // like errtime:errinfo ErrLimit int // max length for the errlist, 0 stand for no limit }
Task task struct
func (*Task) SetCron ¶
SetCron some signals:
*: any time ,: separate signal
-:duration
/n : do as n times of time duration
///////////////////////////////////////////////////////
0/30 * * * * * every 30s 0 43 21 * * * 21:43 0 15 05 * * * 05:15 0 0 17 * * * 17:00 0 0 17 * * 1 17:00 in every Monday 0 0,10 17 * * 0,2,3 17:00 and 17:10 in every Sunday, Tuesday and Wednesday 0 0-10 17 1 * * 17:00 to 17:10 in 1 min duration each time on the first day of month 0 0 0 1,15 * 1 0:00 on the 1st day and 15th day of month 0 42 4 1 * * 4:42 on the 1st day of month 0 0 21 * * 1-6 21:00 from Monday to Saturday 0 0,10,20,30,40,50 * * * * every 10 min duration 0 */10 * * * * every 10 min duration 0 * 1 * * * 1:00 to 1:59 in 1 min duration each time 0 0 1 * * * 1:00 0 0 */1 * * * 0 min of hour in 1 hour duration 0 0 * * * * 0 min of hour in 1 hour duration 0 2 8-20/3 * * * 8:02, 11:02, 14:02, 17:02, 20:02 0 30 5 1,15 * * 5:30 on the 1st day and 15th day of month
type Tasker ¶
type Tasker interface { GetSpec() string GetStatus() string Run() error SetNext(time.Time) GetNext() time.Time SetPrev(time.Time) GetPrev() time.Time }
Tasker task interface
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) GetMapData ¶
GetMapData return all mapdata