schedule

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllRecurrenceKinds is the canonical, closed set of RecurrenceKind values in stable declaration order. Consumers that need to iterate over every kind (e.g. pre-initializing Prometheus counter label combinations) range over this slice — never hand-roll a duplicate slice.

View Source
var SupportedPlaceholders = []string{
	"{{date}}",
	"{{iso-week}}",
	"{{next-iso-week}}",
	"{{month}}",
	"{{last-month}}",
	"{{quarter}}",
	"{{last-quarter}}",
	"{{year}}",
	"{{last-year}}",
}

SupportedPlaceholders lists the EXACT set of placeholders accepted in TitleTemplate and BodyTemplate. Any other `{{...}}` token in an inventory entry is a build-time test failure.

Functions

This section is empty.

Types

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

Date is a civil date (year, month, day) with no time, location, or zone ambiguity in its public surface. It is the only input shape accepted by publisher.Publish and the TasksForDate filter.

func NewDate

func NewDate(year int, month time.Month, day int) Date

NewDate constructs a Date from year/month/day.

func (Date) IsZero

func (d Date) IsZero() bool

IsZero reports whether the Date is the zero value (Year == 0 && Month == 0 && Day == 0).

func (Date) Time

func (d Date) Time() time.Time

Time converts the civil Date to its midnight-UTC carrier time.Time. Pure conversion — no system clock access, no DST math. Provided so consumers can run stdlib time arithmetic (ISOWeek, AddDate, Format) against the carrier without re-implementing the conversion or forcing a duplicate helper in their own package.

type Frontmatter

type Frontmatter = map[string]interface{}

Frontmatter is operator-defined YAML frontmatter stamped onto the generated vault file. Structurally identical to `bborbe/agent/lib`'s `TaskFrontmatter` (`map[string]interface{}`) but declared locally so the pure-data layer here doesn't pull in the agent module just to name a map type. The publisher converts to/from `lib.TaskFrontmatter` at its package boundary.

type RecurrenceKind

type RecurrenceKind string

RecurrenceKind classifies how often an entry repeats. Closed set.

const (
	RecurrenceDaily     RecurrenceKind = "daily"
	RecurrenceWeekly    RecurrenceKind = "weekly"
	RecurrenceWeekday   RecurrenceKind = "weekday"
	RecurrenceMonthly   RecurrenceKind = "monthly"
	RecurrenceQuarterly RecurrenceKind = "quarterly"
	RecurrenceYearly    RecurrenceKind = "yearly"
)

type TaskDefinition

type TaskDefinition struct {
	// Slug is a stable, kebab-case identifier unique across the inventory.
	// Once committed, a slug rename is a breaking change to the future Kafka
	// stream and requires a separate spec.
	Slug string

	// TitleTemplate is the title shown to the user. Supports only the
	// placeholders listed in SupportedPlaceholders below.
	TitleTemplate string

	// BodyTemplate is raw markdown. Supports the same placeholder set.
	BodyTemplate string

	// Recurrence classifies the cadence (daily/weekly/monthly/quarterly/yearly).
	Recurrence RecurrenceKind

	// Weekday is the day of the week the entry is intended for. Its
	// semantics depend on the entry's Recurrence:
	//
	//   - RecurrenceWeekday: REQUIRED (non-zero). The entry fires only on
	//     the day whose weekday equals this value; the publisher appends
	//     the lowercase 3-letter weekday abbreviation to the period token
	//     (e.g. "2026W25-sat"). The disambiguation from RecurrenceWeekly
	//     was introduced in spec 009.
	//
	//   - RecurrenceWeekly: FORBIDDEN (must be the zero value, time.Sunday).
	//     The entry fires on every day inside its ISO week (always-fire
	//     semantic introduced in spec 006); this field is not consulted.
	//     The inventory contains zero RecurrenceWeekly entries after
	//     spec 009 — the kind is reserved for future use.
	//
	//   - RecurrenceDaily / RecurrenceMonthly / RecurrenceQuarterly /
	//     RecurrenceYearly: ignored. May be the zero value or any other
	//     value without effect on firing or rendering.
	Weekday time.Weekday

	// Frontmatter is operator-defined YAML frontmatter stamped onto the
	// generated vault file. Sourced from the `spec.template.frontmatter`
	// field on the Schedule CR (free-form map[string]interface{}). The
	// publisher seeds two defaults (`status: in_progress`,
	// `page_type: task`) and lets operator keys override them on
	// collision. `created_by: recurring-task-creator` is force-set as
	// provenance and cannot be overridden by configuration.
	Frontmatter Frontmatter
}

TaskDefinition is one entry in the recurring-task inventory.

func TasksForDate

func TasksForDate(defs []TaskDefinition, date Date) []TaskDefinition

TasksForDate returns the subset of defs that fires on the given civil date. The caller supplies the definition slice; this function no longer reads a package-level inventory. The filter rule is:

  • RecurrenceDaily, RecurrenceWeekly, RecurrenceMonthly, RecurrenceQuarterly, RecurrenceYearly: always-fire (the entry fires on every day; this is the spec 006 always-fire semantic, preserved by spec 009).
  • RecurrenceWeekday: fires only on the day whose weekday equals the entry's Weekday field. Computed via date.Time().Weekday().

The result is NOT sorted; the caller may sort on Slug if a stable order is required (the HTTP trigger handler does so for the response body).

Pure function: no I/O, no clock, no env. The Europe/Berlin civil-date conversion (and the ISO-week boundary math that goes with it) is the caller's responsibility — this function takes a civil Date, not a time.Time with a location.

An empty defs slice yields an empty slice. A defs slice that contains only RecurrenceWeekday entries whose Weekday does not match the given date's weekday also yields an empty slice.

Jump to

Keyboard shortcuts

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