Documentation
¶
Overview ¶
Package schedule implements in-process reminders: after for relative one-shot delays, at for absolute one-shot times, and every for fixed intervals of at least five minutes. Registration, delivery, and cancellation stay within the owning session.
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 is the minimum periodic interval: five minutes.
Variables ¶
View Source
var ErrEmptyPrompt = errors.New("schedule: empty prompt")
ErrEmptyPrompt indicates empty reminder content.
View Source
var ErrIntervalTooShort = errors.New("schedule: every interval below minimum")
ErrIntervalTooShort indicates an interval below the minimum.
View Source
var ErrNotFuture = errors.New("schedule: target is not in the future")
ErrNotFuture indicates a target time that is not in the future.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID string
Kind Kind
Prompt string
NextAt time.Time
Interval time.Duration // Used only for every.
}
Entry represents an active reminder.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a concurrency-safe in-process scheduler.
func New ¶
func New() *Scheduler
New creates a scheduler that sends dispatches to its output channel.
Click to show internal directories.
Click to hide internal directories.