1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 10:20:39 +00:00

beego task list update for task spec list and task run url error

This commit is contained in:
空见
2015-02-04 18:07:31 +08:00
parent 0e1a0049d1
commit b1baf4503d
3 changed files with 14 additions and 4 deletions

View File

@ -84,6 +84,7 @@ type TaskFunc func() error
// task interface
type Tasker interface {
GetSpec() string
GetStatus() string
Run() error
SetNext(time.Time)
@ -102,6 +103,7 @@ type taskerr struct {
type Task struct {
Taskname string
Spec *Schedule
SpecStr string
DoFunc TaskFunc
Prev time.Time
Next time.Time
@ -116,16 +118,22 @@ func NewTask(tname string, spec string, f TaskFunc) *Task {
Taskname: tname,
DoFunc: f,
ErrLimit: 100,
SpecStr: spec,
}
task.SetCron(spec)
return task
}
//get spec string
func (s *Task) GetSpec() string {
return s.SpecStr
}
// get current task status
func (tk *Task) GetStatus() string {
var str string
for _, v := range tk.Errlist {
str += v.t.String() + ":" + v.errinfo + "\n"
str += v.t.String() + ":" + v.errinfo + "<br>"
}
return str
}