Documentation ¶
Overview ¶
Package cron is a generated GoMock package.
Index ¶
Constants ¶
View Source
const ( ExpressEveryMin = "* * * * *" ExpressEvery5Min = "*/5 * * * *" ExpressEvery10Min = "*/10 * * * *" ExpressEvery30Min = "*/30 * * * *" ExpressEveryHour = "0 * * * *" // 每小时整点执行 ExpressEveryDay = "0 1 * * *" // 凌晨1:00执行 ExpressEveryMonth = "0 1 1 * *" // 每个月 )
cron格式`*/1 * * * *`,分(0-59) 时(0-23) 日(1-31) 月(1-12) 天(0-6)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { TimeZone string // 时区配置,默认为Asia/Shanghai Async bool // 启动job的方式是阻塞还是非阻塞 SingletonModeAll bool // 启动job是否采用单例模式,单例模式下若job如果之前有运行且未完成,则调度器不会重复调度同类型新的job任务(若无特殊要求,推荐开启) }
Config Cron调度器配置
type Locker ¶
type Locker interface { // Lock 分布式加锁 Lock(key string, ttl time.Duration) error // UnLock 分布式解锁 UnLock(key string) error }
Locker 分布式锁接口 该接口主要是针对多个JOB执行时刻,进行并发控制,确保在不同机器上的Job仅执行一次行
type MockLocker ¶
type MockLocker struct {
// contains filtered or unexported fields
}
MockLocker is a mock of Locker interface
func NewMockLocker ¶
func NewMockLocker(ctrl *gomock.Controller) *MockLocker
NewMockLocker creates a new mock instance
func (*MockLocker) EXPECT ¶
func (m *MockLocker) EXPECT() *MockLockerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockLockerMockRecorder ¶
type MockLockerMockRecorder struct {
// contains filtered or unexported fields
}
MockLockerMockRecorder is the mock recorder for MockLocker
func (*MockLockerMockRecorder) Lock ¶
func (mr *MockLockerMockRecorder) Lock(key, ttl interface{}) *gomock.Call
Lock indicates an expected call of Lock
func (*MockLockerMockRecorder) UnLock ¶
func (mr *MockLockerMockRecorder) UnLock(key interface{}) *gomock.Call
UnLock indicates an expected call of UnLock
type RedisLocker ¶
type RedisLocker struct {
// contains filtered or unexported fields
}
RedisLocker 基于Redis实现的分布式锁,
func NewRedisLocker ¶
func NewRedisLocker(redisURL string) (*RedisLocker, error)
NewRedisLocker 创建一个Redis分布式锁 Examples:
redis://user:password@localhost:6789/3?dial_timeout=3&db=1&read_timeout=6s&max_retries=2 is equivalent to: &Options{ Network: "tcp", Addr: "localhost:6789", DB: 1, // path "/3" was overridden by "&db=1" DialTimeout: 3 * time.Second, // no time unit = seconds ReadTimeout: 6 * time.Second, MaxRetries: 2, }
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler Cron调度程序
func NewScheduler ¶
NewScheduler 初始化一个cron 调度器
Click to show internal directories.
Click to hide internal directories.