A light distribute producer&consumer task model based on beego.
- Custom task input, execute logic
- Auto retry after task execute failed
- based on beego orm
go get github.com/NoneBorder/tasker
...
orm.RegisterModel(new(tasker.Task))
...
type ExampleTask struct {
Name string
}
func (self *ExampleTask) New() tasker.MsgQ {
return &ExampleTask{}
}
func (self *ExampleTask) Topic() string {
return "example_task"
}
func (self *ExampleTask) TaskSpec() string {
// beego task spec format
return "*/1 * * * * *"
}
func (self *ExampleTask) Exec(workerID uint64) error {
fmt.Println(self.Name)
return nil
}
tasker.MsgQPublish(&ExampleTask{
Name: "example test",
})
- control consume your self
tasker.MsgQConsume(new(ExampleTask))
- consumer generate as taskspec
tasker.MsgQInitTask(new(ExampleTask))
- NB_TASKER_JUST_WORKER: the instance will not race to become master when the environment set to "ON"
The MIT License (MIT)