Documentation
¶
Overview ¶
Package service 服务管理
Index ¶
- type Func
- type Manager
- func (mgr *Manager) AddAt(title string, f scheduled.JobFunc, t time.Time, delay bool) error
- func (mgr *Manager) AddCron(title string, f scheduled.JobFunc, spec string, delay bool) error
- func (mgr *Manager) AddJob(title string, f scheduled.JobFunc, scheduler schedulers.Scheduler, delay bool)
- func (mgr *Manager) AddService(title string, f Func)
- func (mgr *Manager) AddTicker(title string, f scheduled.JobFunc, dur time.Duration, imm, delay bool) error
- func (mgr *Manager) Jobs() []*scheduled.Job
- func (mgr *Manager) Run()
- func (mgr *Manager) Services() []*Service
- func (mgr *Manager) Stop()
- type Service
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
Func 服务实际需要执行的函数
实现者需要正确处理 ctx.Done 事件,调用者可能会主动取消函数执行; 如果是通 ctx.Done 取消的,应该返回 context.Canceled。
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 服务管理
func NewManager ¶
NewManager 返回 Manager
func (*Manager) AddAt ¶ added in v0.34.0
AddAt 添加新的定时任务
f 表示服务的运行函数; title 是对该服务的简要说明; t 指定的时间点; delay 是否在任务执行完之后,才计算下一次的执行时间点。
func (*Manager) AddCron ¶ added in v0.34.0
AddCron 添加新的定时任务
f 表示服务的运行函数; title 是对该服务的简要说明; spec cron 表达式,支持秒; delay 是否在任务执行完之后,才计算下一次的执行时间点。
func (*Manager) AddJob ¶ added in v0.34.0
func (mgr *Manager) AddJob(title string, f scheduled.JobFunc, scheduler schedulers.Scheduler, delay bool)
AddJob 添加新的计划任务
f 表示服务的运行函数; title 是对该服务的简要说明; scheduler 计划任务的时间调度算法实现; delay 是否在任务执行完之后,才计算下一次的执行时间点。
func (*Manager) AddService ¶
AddService 添加新的服务
f 表示服务的运行函数; title 是对该服务的简要说明。
NOTE: 如果 Manager 的所有服务已经处于运行的状态,则会自动运行新添加的服务。
Click to show internal directories.
Click to hide internal directories.