Documentation
¶
Overview ¶
Package controlsource connects the manifest reader to the runtime: it turns every manifestreader.Snapshot into a flagruntime.Content and hands it to the engine.
It is a separate package so that flagruntime does not import the reader (the runtime knows contents, not where they come from) and the reader does not import the runtime. The package imports no HTTP code: Source.Status joins the status of the reader with the result of the engine and the status tree of the running runtime, for the readiness and observability code that comes later.
The package is built beside the running relay: nothing in the relay uses it yet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶
func Content(snap *manifestreader.Snapshot) *flagruntime.Content
Content maps a snapshot to the content of the engine. The bytes of an object are not copied: the content shares them with the snapshot (both are immutable). The states are mapped one to one: ok, stale and missing; a state that this version does not know is reported as missing with the reason it came with, so the engine keeps the last good content of the object.
Types ¶
type Engine ¶
type Engine interface {
// Submit hands a content to the engine without blocking (latest wins).
Submit(content *flagruntime.Content)
// Result is the result of the last round of the engine.
Result() flagruntime.RoundResult
}
Engine is what the source needs from the reconcile engine: *flagruntime.Engine implements it.
type Reader ¶
type Reader interface {
// Snapshots is the latest-wins channel of snapshots; it is closed when the reader stops.
Snapshots() <-chan *manifestreader.Snapshot
// Status is the state of the reader at the end of its last round.
Status() manifestreader.Status
}
Reader is what the source needs from the manifest reader: *manifestreader.Reader implements it.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source runs the goroutine that feeds the engine from the reader.
func New ¶
New returns a source. holder is the holder the engine stores into; a nil logger discards.
func (*Source) Run ¶
Run consumes the snapshots of the reader until ctx is done or the reader closes its channel, and returns then. It starts no goroutine of its own: it is the one goroutine of the source, so nothing is left behind. The reader delivers latest-wins into a channel of one, and the engine's Submit is latest-wins too: a burst of snapshots reaches the engine as its newest content, never as a queue. Run must be called once.
type Status ¶
type Status struct {
// Round is the result of the last round of the engine, applied, ignored or rejected.
Round flagruntime.RoundResult `json:"round"`
// Runtime is the status tree of the runtime that serves now.
Runtime *flagruntime.Status `json:"runtime"`
// Reader is the status of the manifest reader.
Reader manifestreader.Status `json:"reader"`
// Received counts the snapshots the source took from the reader and handed to the engine.
Received uint64 `json:"received"`
// LastGeneration is the generation of the last snapshot that was handed to the engine.
LastGeneration uint64 `json:"lastGeneration"`
}
Status is the joined status of the reader, the source and the engine. It never holds an API key or the bytes of an object. Its fields are values or immutable trees, safe to hand to an encoder.