Documentation
¶
Overview ¶
Package schedule 复刻官方 schedule 的进程内调度核心:after(延迟一次性)、 at(绝对时刻一次性)、every(固定周期,不低于 5 分钟)三类提醒的注册、触发与 取消。提醒投递不离开拥有者会话(session-local)。
Index ¶
- Constants
- Variables
- type Dispatch
- type Entry
- type Kind
- type Scheduler
- func (s *Scheduler) After(id, prompt string, delay time.Duration) error
- func (s *Scheduler) At(id, prompt string, at time.Time) error
- func (s *Scheduler) Cancel(id string) bool
- func (s *Scheduler) Every(id, prompt string, interval time.Duration) error
- func (s *Scheduler) List() []Entry
- func (s *Scheduler) Out() <-chan Dispatch
- func (s *Scheduler) SetNow(f func() time.Time)
- func (s *Scheduler) Shutdown()
Constants ¶
View Source
const MinEveryInterval = 5 * time.Minute
MinEveryInterval 是固定周期规则允许的最小间隔(5 分钟)。
Variables ¶
View Source
var ErrEmptyPrompt = errors.New("schedule: empty prompt")
ErrEmptyPrompt 提醒内容为空。
View Source
var ErrIntervalTooShort = errors.New("schedule: every interval below minimum")
ErrIntervalTooShort 周期小于最小值。
View Source
var ErrNotFuture = errors.New("schedule: target is not in the future")
ErrNotFuture 目标时刻不在未来。
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID string
Kind Kind
Prompt string
NextAt time.Time
Interval time.Duration // 仅 every
}
Entry 是一条活动提醒。
Click to show internal directories.
Click to hide internal directories.