engine

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package engine orchestrates a run: it expands a Saga into scan jobs (controllers × components), executes them with bounded parallelism, and aggregates each control's results. Content-hash caching and the full describe→publish pipeline build on this.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine plans and runs scans against a registry of controllers and scanners.

func New

func New(reg *Registry, opts ...Option) *Engine

New creates an Engine over the given registry. By default it runs up to NumCPU jobs concurrently.

func (*Engine) Plan

func (e *Engine) Plan(model saga.Model) ([]PlannedJob, error)

Plan expands the model into scan jobs. Only registered controllers that are enabled (project-level for project-scoped controllers, per-component for component-scoped ones) are planned. Controllers are visited in name order for determinism.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, model saga.Model) (Result, error)

Run plans and executes scans with bounded concurrency, then aggregates per control. Scan errors do not abort the run; they are collected and returned (joined) alongside whatever results succeeded. Honors ctx cancellation.

type Option

type Option func(*Engine)

Option configures an Engine.

func WithCache

func WithCache(c cache.Cache) Option

WithCache enables result caching: a cache hit for a job's key reuses the stored report instead of re-scanning. A nil cache disables caching (the default).

func WithConcurrency

func WithConcurrency(n int) Option

WithConcurrency sets the maximum number of scan jobs running at once. Values < 1 are ignored (the default is used).

type PlannedJob

type PlannedJob struct {
	Control string
	Job     plugin.ScanJob
}

PlannedJob is a scan job tagged with the control that produced it.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the controllers and scanners available to the engine, keyed by name.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Controller

func (r *Registry) Controller(name string) (plugin.Controller, bool)

Controller returns the named controller, if registered.

func (*Registry) RegisterController

func (r *Registry) RegisterController(c plugin.Controller)

RegisterController adds a controller, keyed by its Info().Name.

func (*Registry) RegisterScanner

func (r *Registry) RegisterScanner(s plugin.Scanner)

RegisterScanner adds a scanner, keyed by its Info().Name.

func (*Registry) Scanner

func (r *Registry) Scanner(name string) (plugin.Scanner, bool)

Scanner returns the named scanner, if registered.

type Result

type Result struct {
	Controls map[string]plugin.ControlResult
	Stats    Stats
}

Result is the outcome of a run: one aggregated ControlResult per control, plus run statistics.

type Stats

type Stats struct {
	Jobs      int
	Scans     int
	CacheHits int
}

Stats summarizes execution, including cache effectiveness.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL