Documentation
¶
Overview ¶
Package engine wires together the base plugin, the core plugin runner, and the active template into a single Compute call. The engine owns no business logic of its own; it sequences pieces from internal/plugins, internal/templates, and internal/config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal serializes the populated Data structure into the upstream- compatible JSON shape.
The wire format mirrors upstream lowlighter/metrics output keys (account, user, config, computed, plugins, errors) while normalizing Go-only details (time.Time → RFC 3339, Token → "(provided)" mask, maps with non-string keys → [{key,value}] arrays, sets → sorted slices). Cycles in Data.Plugins[*] are replaced with the literal string "[Circular]" so the call never panics on pathological inputs.
func SetVersion ¶
func SetVersion(v string)
SetVersion is the production setter, called by cmd mains at initialization when they want to override the linker-injected value (e.g. when the binary embeds version metadata from another source).
func SetVersionForTest ¶
SetVersionForTest swaps the package-level version under a test scope. The original value is restored via t.Cleanup so individual tests stay isolated.
Types ¶
type Deps ¶
type Deps struct {
Settings *config.Settings
Metadata *config.MetadataLoader
Logger *slog.Logger
HTTPClient *httpx.Client
REST *githubapi.REST
GraphQL *githubapi.GraphQL
// Render performs the chromedp-backed SVG resize / convert and is
// consumed only when Request.Format ∈ {"svg","png","jpeg"}. Nil
// is permitted: when needed, Compute lazily allocates a default
// *render.Browser on first use and tears it down at the end of
// the call. Tests should inject a *render.FakeRenderer so they
// never start chromium. JSON-format requests never read this
// field.
Render render.Renderer
}
Deps groups the long-lived collaborators the engine reuses across Compute calls. Construct one per process.
type Request ¶
type Request struct {
// Login is the GitHub login the engine should compute metrics for.
Login string
// Repo is the repository name when Template == "repository" (M7).
// Empty for the classic user / organization templates. Combined
// with Login as `<Login>/<Repo>` to form the GitHub identifier.
Repo string
// Template is the registered template name to invoke for output.
// Pass "noop" (or any registered no-op template) to wire the
// pipeline without actually rendering anything (M1 default).
Template string
// Format is "svg" / "png" / "jpeg" / "json"; the active Template
// validates it via Check.
Format string
// Account hints the kind we are computing for; engine falls back
// to AccountUser when empty.
Account plugins.AccountKind
// Inputs is the normalized input map produced by
// config.NewInputs(...).ForAction (or ForWeb / ForData).
Inputs map[string]any
// Parallel caps the number of plugin goroutines core.RunPlugins
// spawns. Zero falls back to runtime.GOMAXPROCS.
Parallel int
// Die selects the per-plugin failure semantics: when true, the
// first plugin error aborts the request; when false, errors are
// collected in Result.Data.Plugins[name] and Compute still returns
// nil (matching upstream `die=false`).
Die bool
}
Request groups the per-call inputs the engine consumes.
type Result ¶
type Result struct {
// Data is the fully populated internal state. M2 onward consumes
// it via the JSON marshaller and template render path.
Data *plugins.Data
// Errors aggregates non-fatal plugin errors when Die == false.
Errors []error
// Output is the serialized payload in the requested format.
// Populated by Compute after the dispatch stage runs. Valid IANA
// values for the corresponding MIME (see [Result.MIME]):
//
// application/json when Request.Format == "json"
// image/svg+xml when Request.Format == "svg" (Template.Run
// output after
// the M3
// decoration
// pipeline +
// chromedp
// svg.Resize)
// image/png when Request.Format == "png" (real PNG
// bytes from
// chromedp
// page.CaptureScreenshot,
// M3+)
// image/jpeg when Request.Format == "jpeg" (same as PNG
// with JPEG
// format)
//
// On Renderer failure for png / jpeg paths the dispatch returns
// (nil, "") and appends the chromedp error to Result.Errors so
// callers can detect the failure via the empty Output (FR-018).
// For svg the dispatch falls back to the un-resized decorated
// SVG bytes.
Output []byte
// MIME is the IANA type that matches Output. Never empty when
// Output is set; never set when Output is empty.
MIME string
}
Result is the engine's output.