blockio

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 12 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 blockio provides CUE-validated YAML import/export for scheduling blocks, plus first-run bootstrap of a static scheduler file into the block store (see Bootstrap in bootstrap.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(ctx context.Context, s *store.Store, path string, logger *slog.Logger) (int, error)

Bootstrap performs first-run import of a static scheduler YAML file into the block store.

Behavior:

  • If the store already has one or more blocks, Bootstrap is a no-op and returns (0, nil): the store is the source of truth once it has been populated, and a static file must never silently re-seed or duplicate data on every restart.
  • If the store is empty but path does not exist, Bootstrap is a no-op and returns (0, nil): there is nothing to import.
  • If the store is empty and path exists, Bootstrap parses and validates the file (via ParseYAML) and creates one BlockRecord per block, with a generated UUID as the ID, the block's Name, and Enabled set to true. It returns the number of blocks imported.
  • If the file exists but fails to parse or validate, Bootstrap returns an error and imports nothing: validation happens on the whole file before any block is written, so a bad file can never leave the store half-imported.

func ParseYAML

func ParseYAML(data []byte) ([]scheduler.Block, error)

ParseYAML strictly decodes YAML data into scheduling blocks and validates the result against the CUE schema via ValidateBlocks. Decoding is strict: unknown fields anywhere in the document are rejected rather than silently ignored.

ParseYAML also rejects blocks that share a name. This lives here, ahead of ValidateBlocks, rather than inside ValidateBlocks or left for the store to catch: CUE validates each block against #Block independently and has no notion of "list of blocks with unique names," so two same-named blocks in one file would otherwise sail through CUE validation cleanly. Catching it here -- before any block from this file is written anywhere -- protects every YAML-driven import path (Bootstrap today, a future import API endpoint tomorrow) uniformly, without requiring store-level transactions: a duplicate never gets far enough to hit store.ErrConflict partway through a batch of writes.

func RenderYAML

func RenderYAML(blocks []scheduler.Block) ([]byte, error)

RenderYAML renders blocks as YAML, wrapped in the scheduler.Config envelope used by scheduler files. Because it marshals a typed struct (scheduler.Config) rather than a map, field order is stable across calls: it always follows the struct's declared field order, not map iteration order.

func ValidateBlocks

func ValidateBlocks(blocks []scheduler.Block) error

ValidateBlocks validates blocks against the scheduler CUE schema. It renders the blocks to YAML (via RenderYAML) and runs the result through cueconfig's scheduler validator, wrapping any resulting CUE error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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