Documentation
¶
Overview ¶
Package trigger notifies downstream rebuild machinery that grains changed: after a publish, something must re-run serialize/project/index and redeploy the static site. The Notifier seam keeps that transport pluggable -- a webhook toward any CI system here, SQS/EventBridge in trigger/awstrigger -- and noop for setups that rebuild on a schedule.
Index ¶
Constants ¶
const SignatureHeader = "X-Lcat-Signature"
SignatureHeader carries the webhook body's HMAC-SHA256 (hex).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Coalesce ¶
type Coalesce struct {
Next Notifier
// Window is the quiet period that closes a batch. Default 5s.
Window time.Duration
// MaxDelay bounds how long a busy stream can hold the batch open,
// measured from its first event. Default 12x Window.
MaxDelay time.Duration
// Timeout bounds one downstream delivery. Default 10 minutes.
Timeout time.Duration
Logger *slog.Logger
// contains filtered or unexported fields
}
Coalesce batches a burst of events into one downstream Notify carrying the union of changed paths: an editing session's stream of publishes becomes one incremental rebuild instead of one per save. The batch fires after Window of quiet, or MaxDelay after its first event, whichever comes first. Notify itself never blocks on the downstream -- delivery runs on its own goroutine with its own deadline, and a failure is logged, not returned, because the publish that triggered it has already succeeded (scheduled full rebuilds stay the correctness backstop).
type Command ¶
type Command struct {
// Shell command, run via sh -c.
Cmd string
// Dir is the working directory ("" = inherited).
Dir string
// Timeout bounds one run. Default 5 minutes.
Timeout time.Duration
// Logger receives run results. nil disables logging.
Logger *slog.Logger
// contains filtered or unexported fields
}
Command runs a shell command on every event -- the local dev loop: point it at "lcat serialize && lcat project" targeting a running `hugo server`'s data directory and published edits appear in the discovery site within seconds, no cloud, no CI (the hugo-watcher idea). The changed blob paths arrive newline-joined in $LCAT_CHANGED_PATHS.
type Event ¶
type Event struct {
// Kind is the event class, e.g. "grains-changed".
Kind string `json:"kind"`
// Paths lists the changed blob paths (grain files).
Paths []string `json:"paths"`
At time.Time `json:"at"`
}
Event describes one batch of grain changes.
type Fanout ¶
type Fanout []Notifier
Fanout delivers each event to every notifier, returning the first error after all have run (a failing webhook must not starve the local rebuild).
type Webhook ¶
type Webhook struct {
URL string
Secret []byte
// Client overrides the HTTP client (tests). nil = http.DefaultClient.
Client *http.Client
}
Webhook POSTs each event as JSON to a URL, signed with an HMAC so the receiver can authenticate the sender (CI webhook endpoints are otherwise unauthenticated).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package awstrigger delivers trigger events over AWS messaging: an SQS queue (a worker consumes and rebuilds) or an EventBridge bus (fan-out to CodeBuild/Step Functions).
|
Package awstrigger delivers trigger events over AWS messaging: an SQS queue (a worker consumes and rebuilds) or an EventBridge bus (fan-out to CodeBuild/Step Functions). |