Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartCronJob ¶
func StartCronJob(c *cron.Cron, jobBuilder CronJobBuilder, schedule string) (cron.EntryID, error)
StartCronJob 启动定时任务
Types ¶
type CronJobBuilder ¶
func NewCronJobBuilder ¶
func NewCronJobBuilder(name string, run func() error, l *zap.Logger) CronJobBuilder
type Executor ¶
type Executor interface { Name() string Exec(ctx context.Context, dj domain.Job) error RegisterFunc(name string, fn func(ctx context.Context, dj domain.Job) error) }
Executor 定义了任务执行器接口
func NewLocalFuncExecutor ¶
func NewLocalFuncExecutor() Executor
NewLocalFuncExecutor 创建并初始化 LocalFuncExecutor 实例
type LocalFuncExecutor ¶
type LocalFuncExecutor struct {
// contains filtered or unexported fields
}
LocalFuncExecutor 本地方法执行器
func (*LocalFuncExecutor) RegisterFunc ¶
func (l *LocalFuncExecutor) RegisterFunc(name string, fn func(ctx context.Context, dj domain.Job) error)
RegisterFunc 注册本地执行函数
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func NewScheduler(svc service.CronJobService, l *zap.Logger) *Scheduler
func (*Scheduler) RegisterExecutor ¶
RegisterExecutor 注册任务执行器
Click to show internal directories.
Click to hide internal directories.