Documentation
¶
Overview ¶
Package trigger polls resources named by a get step's trigger: true and runs every job affected by a version change — the cross-job counterpart to internal/pipeline's single-job orchestration. A job is enqueued (into a durable, sqlite-backed queue on internal/store's Store) rather than run directly, so the poller and the job runner can operate as two independent loops: this is what gives durability (a crash mid-run doesn't lose track of what was pending) and a real concurrency cap, versus an in-memory dedup set that forgets everything on restart and has no limit.
Index ¶
- func AffectedJobs(cfg *config.Config, resourceName string) []*config.Job
- func DeliverLocally(ctx context.Context, cfg *config.Config, st HookStore, name string, raw []byte) error
- func HookHandler(current ConfigSource, st HookStore) func(w http.ResponseWriter, r *http.Request, resource string)
- func Poll(ctx context.Context, current ConfigSource, st PollStore, ...) error
- func Resources(cfg *config.Config) []string
- type ConfigSource
- type HookStore
- type PollStore
- type SharedChecks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AffectedJobs ¶
AffectedJobs returns every job that has a trigger:true get step resolving to resourceName, in declaration order. A job with more than one such step on the same resource is returned once. Matching is on the resolved resource name (get: aliases included), matching Resources — including a trigger:true get nested inside an in_parallel:/race: branch, which config.Job.TriggersOn walks the same tree config.PolledResourceNames does to find.
func DeliverLocally ¶
func DeliverLocally(ctx context.Context, cfg *config.Config, st HookStore, name string, raw []byte) error
DeliverLocally records a captured delivery for a local command, which has no daemon to POST to. It runs the pipeline's own filter:, id: and version: and skips only the signature — a local command holds no secret, and the signature schemes are proven by their own fixtures. Nothing is queued: the command runs the job itself.
func HookHandler ¶
func HookHandler(current ConfigSource, st HookStore) func(w http.ResponseWriter, r *http.Request, resource string)
HookHandler answers deliveries to one pipeline's webhook resources. The configuration is read per request, as Poll reads it per cycle, because a set swaps it while this stays mounted.
func Poll ¶
Poll is the producer half of the daemon: it checks every trigger: true resource on an interval and enqueues the jobs a version change affects, until ctx is canceled. It never drains the queue — `steps web` drains it through its own in-process runner, and a second set of workers here would claim rows out from under it.
Two things stay the caller's:
- startup reconciliation (ResetStaleRunning and the serial-group / max-in-flight syncs). Whoever owns the drain owns that, since it is the drain's admission it repairs.
- the configuration, as a SOURCE rather than a value. A `steps pipeline set` replaces it while this loop runs, and a loop holding the config it started with would go on checking resources the operator deleted and never check the ones they added. Each cycle reads the current one, and admission re-validates and re-preflights whenever it changes.
func Resources ¶
Resources returns the distinct resource names referenced by any get step with trigger: true, anywhere in any job's plan, in first-seen order. A get step's resource: alias is resolved to the underlying resource name (see config.Step.GetResourceName), so two gets aliasing the same resource poll it once and a version change affects every job that references it.
Delegates to config.Config.PolledResourceNames, which carries the full doc on why passed: counts alongside trigger: true — internal/pipeline needs the same predicate (to know which resources NOT to touch when recording a run's resolved version) and cannot import this package, since this package already imports internal/pipeline.
Types ¶
type ConfigSource ¶
ConfigSource hands out the configuration to poll against, which the daemon swaps under this loop when the pipeline is set again.
type HookStore ¶
type HookStore interface {
PollStore
store.Deliveries
}
HookStore is what a delivery touches: the jobs it may queue, whether the pipeline is paused, and the delivery itself.
type PollStore ¶
PollStore is what polling touches: the queue it fills, the versions a check compares against, and whether the pipeline is paused.
type SharedChecks ¶
type SharedChecks struct {
// contains filtered or unexported fields
}
SharedChecks is one process's share of identical checks across the pipelines it polls (see resource.CheckShare). Only polls take part: a build checks for itself, because a person who triggers one right after a push wants what exists now, not what a poll saw.
func NewSharedChecks ¶
func NewSharedChecks(interval time.Duration) *SharedChecks
NewSharedChecks reuses an answer for half an interval, so a pipeline's poll sees a version no later than a poll half an interval earlier would have.