Documentation
¶
Overview ¶
Package schedule provides in-process delayed, periodic, and idle triggers for agent hosts, such as chat-idle context cleanup and future self-triggering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
Func is called with a context cancelled when its task is cancelled or the scheduler closes.
type Handle ¶
type Handle interface {
Cancel() // unregister the task; a running call sees its ctx cancelled
Reset() // restart the timer from now
Pause() // stop the timer until Resume
Resume() // restart the timer from now
}
Handle controls one registered task.
type Option ¶
type Option func(*scheduler)
Option configures New.
func WithObserver ¶
WithObserver sets the event callback, called outside the scheduler lock. Events of one run may arrive out of order ("done" before "fired" for a very short run); order by Event.At when it matters.
type Scheduler ¶
type Scheduler interface {
After(name string, d time.Duration, fn Func) Handle // fire once after d, then unregister
Every(name string, d time.Duration, fn Func) Handle // fire every d
Idle(name string, d time.Duration, fn Func) Handle // fire once d after the last Touch, then wait for the next Touch
Touch() // activity: restart every Idle timer
Close() error // cancel all tasks and wait for running ones
}
Scheduler runs named delayed, periodic and idle tasks in-process. Registering a name again replaces the old task; one task never runs concurrently with itself; observers are called outside the scheduler lock, so they may call back into the scheduler.