2023-06-05 13:37:32 +08:00
|
|
|
package contracts
|
|
|
|
|
2023-06-05 16:52:03 +08:00
|
|
|
import (
|
|
|
|
"github.com/samber/do"
|
|
|
|
)
|
|
|
|
|
2023-06-06 10:14:16 +08:00
|
|
|
type JobService interface {
|
2023-06-05 13:37:32 +08:00
|
|
|
Start() error
|
|
|
|
Stop() error
|
|
|
|
Restart() error
|
|
|
|
Dispatch(job string, payload any, u User) error
|
|
|
|
}
|
2023-06-05 16:52:03 +08:00
|
|
|
|
|
|
|
type Job interface {
|
|
|
|
Controller
|
|
|
|
// 任务处理
|
|
|
|
Handle(any) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobBase struct {
|
|
|
|
Controller
|
|
|
|
}
|
|
|
|
|
|
|
|
func (JobBase) Handle(any) error {
|
2023-06-05 17:32:10 +08:00
|
|
|
return nil
|
2023-06-05 16:52:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewJobBase(container *do.Injector) Job {
|
|
|
|
return &JobBase{
|
|
|
|
Controller: &BaseController{container},
|
|
|
|
}
|
|
|
|
}
|