sched

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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