toolbox

package
v0.6.1-0...-03080b3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2014 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminCheckList map[string]HealthChecker

health checker map

View Source
var (
	AdminTaskList map[string]Tasker
)

The bounds for each field.

Functions

func AddHealthCheck

func AddHealthCheck(name string, hc HealthChecker)

add health checker with name string

func AddTask

func AddTask(taskname string, t Tasker)

add task with name

func Display

func Display(data ...interface{})

print the data in console

func GetDisplayString

func GetDisplayString(data ...interface{}) string

return data print string

func MemProf

func MemProf()

record memory profile in pprof

func PrintGCSummary

func PrintGCSummary(w io.Writer)

print gc information to io.Writer

func ProcessInput

func ProcessInput(input string, w io.Writer)

parse input command string

func StartCPUProfile

func StartCPUProfile()

start cpu profile monitor

func StartTask

func StartTask()

start all tasks

func StopCPUProfile

func StopCPUProfile()

stop cpu profile monitor

func StopTask

func StopTask()

start all tasks

Types

type HealthChecker

type HealthChecker interface {
	Check() error
}

health checker interface

type MapSorter

type MapSorter struct {
	Keys []string
	Vals []Tasker
}

sort map for tasker

func NewMapSorter

func NewMapSorter(m map[string]Tasker) *MapSorter

create new tasker map

func (*MapSorter) Len

func (ms *MapSorter) Len() int

func (*MapSorter) Less

func (ms *MapSorter) Less(i, j int) bool

func (*MapSorter) Sort

func (ms *MapSorter) Sort()

sort tasker map

func (*MapSorter) Swap

func (ms *MapSorter) Swap(i, j int)

type Schedule

type Schedule struct {
	Second uint64
	Minute uint64
	Hour   uint64
	Day    uint64
	Month  uint64
	Week   uint64
}

time taks schedule

func (*Schedule) Next

func (s *Schedule) Next(t time.Time) time.Time

set schedule to next time

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
	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 struct

func NewTask

func NewTask(tname string, spec string, f TaskFunc) *Task

add new task with name, time and func

func (*Task) GetNext

func (tk *Task) GetNext() time.Time

get the next call time of this task

func (*Task) GetPrev

func (tk *Task) GetPrev() time.Time

get prev time of this task

func (*Task) GetStatus

func (tk *Task) GetStatus() string

get current task status

func (*Task) Run

func (tk *Task) Run() error

run task

func (*Task) SetCron

func (t *Task) SetCron(spec string)

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

func (*Task) SetNext

func (tk *Task) SetNext(now time.Time)

set next time for this task

func (*Task) SetPrev

func (tk *Task) SetPrev(now time.Time)

set prev time of this task

type TaskFunc

type TaskFunc func() error

task func type

type Tasker

type Tasker interface {
	GetStatus() string
	Run() error
	SetNext(time.Time)
	GetNext() time.Time
	SetPrev(time.Time)
	GetPrev() time.Time
}

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

global statistics data map

func (*UrlMap) AddStatistics

func (m *UrlMap) AddStatistics(requestMethod, requestUrl, requestController string, requesttime time.Duration)

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

func (*UrlMap) GetMap

func (m *UrlMap) GetMap(rw io.Writer)

put url statistics result in io.Writer

Jump to

Keyboard shortcuts

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