Stitch any CI into Tangled
1package main
2
3// Provider is the abstraction over "the thing that turns a Tangled
4// pipeline trigger into pipeline.status events". It exists so the rest
5// of tack can stay agnostic to whether a given trigger is dispatched to
6// Buildkite, run by a stub for testing, or anything else we plug in later.
7
8import (
9 "context"
10
11 "tangled.org/core/api/tangled"
12)
13
14// Provider dispatches a Tangled pipeline trigger to whatever backend
15// actually runs the workflows.
16//
17// Implementations are responsible for publishing
18// sh.tangled.pipeline.status records back through whatever channel
19// they were constructed with.
20type Provider interface {
21 // Spawn kicks off a pipeline run for every workflow in workflows.
22 //
23 // It MUST be non-blocking: the caller is the eventconsumer worker
24 // that's shared across all knot subscriptions, so per-pipeline
25 // work has to live on its own goroutine. A typical implementation
26 // fans out into a goroutine per workflow and returns immediately.
27 //
28 // ctx is the consumer's app-scoped context (lives until shutdown,
29 // not just for the duration of one event). Implementations are
30 // expected to honour cancellation: in-flight runs should wind
31 // down without issuing further publishes once ctx is done.
32 //
33 // knot is the knot hostname the trigger arrived on; it's the
34 // authority half of the pipeline ATURI that pipeline.status
35 // records reference. pipelineRkey is the trigger record's rkey
36 // on that knot. workflows is the unmodified slice from the
37 // decoded sh.tangled.pipeline record; implementations should
38 // tolerate nil entries and zero-length names defensively, since
39 // the lexicon doesn't enforce either.
40 Spawn(
41 ctx context.Context,
42 knot string,
43 pipelineRkey string,
44 workflows []*tangled.Pipeline_Workflow,
45 )
46}