Documentation
¶
Overview ¶
Package schedule runs explicitly registered, process-local recurring tasks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
Event describes a start, result, or skipped busy trigger. DurationMS is set on terminal events. Err can contain application data and is not public text.
type Options ¶
type Options struct {
OnEvent func(Event)
}
Options supplies an optional execution observer. OnEvent can run concurrently even for the same task and must return promptly. It must not call Shutdown synchronously. Nil uses slog.Default (failures at ERROR, other events DEBUG).
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
PanicError retains a task panic and its stack for trusted observability sinks.
func (*PanicError) Error ¶
func (e *PanicError) Error() string
func (*PanicError) Stack ¶
func (e *PanicError) Stack() []byte
Stack returns an independent copy of the captured stack.
func (*PanicError) Unwrap ¶
func (e *PanicError) Unwrap() error
func (*PanicError) Value ¶
func (e *PanicError) Value() any
Value returns the original panic payload, not necessarily an error.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a one-shot app.Service. Task failures are execution events; they do not terminate scheduling or trigger immediate retries.
func New ¶
New validates all registrations and snapshots the task slice. Each name must be unique. Durations are milliseconds and are checked before conversion.
type Task ¶
type Task struct {
Name string
IntervalMS int64
Cron string
Timezone string
TimeoutMS int64
Run func(context.Context) error
}
Task describes an immutable registration. Set exactly one of IntervalMS or Cron. Cron uses five fields (minute/hour/day/month/weekday) and requires an explicit IANA Timezone. TimeoutMS zero disables the cooperative time limit. Run must honor cancellation; the scheduler cannot terminate a goroutine.