-
Notifications
You must be signed in to change notification settings - Fork 6
/
interface.go
33 lines (27 loc) · 1.19 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package schedule
type JobName string
// RunFuncOnceAt 定时跑
// @Param fn 要调用的函数
// @Param spec 调用时间 cron tab 格式
// ┌───────────── second (0 - 59)
// │ ┌───────────── minute (0 - 59)
// │ │ ┌───────────── hour (0 - 23)
// │ │ │ ┌───────────── day of the month (1 - 31)
// │ │ │ │ ┌───────────── month (1 - 12)
// │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
// │ │ │ │ │ │ 7 is also Sunday on some systems)
// │ │ │ │ │ │
// │ │ │ │ │ │
// * * * * * *
// @Param lockKey 分布式锁的key
// @Param lockTtl 锁定时长
type RunFuncOnceAt func(spec string, jobName JobName, fn func())
//go:generate sh -c "mockgen -package=schedule -self_package=github.com/gone-io/gone/goner/schedule -source=interface.go|gone mock -o mock_test.go"
type Scheduler interface {
//Cron use: Cron(run facility.RunFuncOnceAt)
Cron(run RunFuncOnceAt)
}
type Schedule interface {
Start() error
Stop() error
}