sched

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sched holds packtrail's use of JetStream message scheduling: the validator for cron expressions (so a typo fails at registration instead of inside the engine) and the header set for durable one-shot timers and cron schedules.

Index

Constants

View Source
const (
	HeaderSchedule       = "Nats-Schedule"
	HeaderScheduleTarget = "Nats-Schedule-Target"
	HeaderScheduleTZ     = "Nats-Schedule-Time-Zone"
	HeaderScheduler      = "Nats-Scheduler"
	HeaderScheduleNext   = "Nats-Schedule-Next"
)

NATS message-scheduling headers.

Variables

This section is empty.

Functions

func At

func At(t time.Time) string

At returns the schedule pattern firing once at t. The server parses @at with time.RFC3339, which accepts fractional seconds, and fires a past time immediately. The fraction is kept: a time truncated to the second fires up to a second early — a 1 s attempt timeout could fire almost at once (found with G5-02).

func ValidateCron

func ValidateCron(expr string) error

ValidateCron reports whether expr is a schedule the NATS server will accept, without publishing anything.

The grammar mirrors the server's parser (server/cron.go): the predefined `@` schedules, `@every <duration>` (at least one second), `@at <RFC3339 time>`, or six space-separated fields

second minute hour day-of-month month day-of-week

each a comma-separated list of terms, where a term is `*`, `?`, a number or a name, optionally a `-`-range, optionally followed by `/step`. Like the server, empty comma terms are skipped and anything after `*`/`?` in a range is ignored. `@every`/`@at` arguments are fully parsed, not accepted on shape alone.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL