Documentation ¶
Overview ¶
Package driver contains a Driver implementation that sends analyses to a CompilationAnalyzer based on a Queue of compilations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRetry can be returned from a Driver's AnalysisError function to signal // that the driver should retry the analysis immediately. ErrRetry = goerrors.New("retry analysis") // ErrEndOfQueue can be returned from a Queue to signal there are no // compilations left to analyze. ErrEndOfQueue = goerrors.New("end of queue") )
Functions ¶
This section is empty.
Types ¶
type Compilation ¶ added in v0.0.27
type Compilation struct { Unit *apb.CompilationUnit // the compilation to analyze Revision string // revision marker to attribute to the compilation UnitDigest string // unit digest identifying the compilation in a KCD BuildID string // id of the build executing the compilation }
A Compilation represents a compilation and other metadata needed to analyze it.
type CompilationFunc ¶
type CompilationFunc func(context.Context, Compilation) error
CompilationFunc handles a single CompilationUnit.
type Context ¶ added in v0.0.27
type Context interface { // Setup is invoked after a compilation has been fetched from a Queue but // before it is sent to the analyzer. If Setup reports an error, analysis // is aborted. Setup(context.Context, Compilation) error // Teardown is invoked after a analysis has completed for the compilation. // If Teardown reports an error after analysis succeeds, it is logged but // does not cause the analysis to fail. Teardown(context.Context, Compilation) error // AnalysisError is invoked for each non-nil error reported by the analyzer // prior to calling Teardown. The error returned from AnalysisError replaces // the error returned by the analyzer itself. // // If AnalysisError returns the special value ErrRetry, the analysis is // retried immediately. AnalysisError(context.Context, Compilation, error) error }
A Context packages callbacks invoked during analysis.
type Driver ¶
type Driver struct { Analyzer analysis.CompilationAnalyzer FileDataService string Context Context // if nil, callbacks are no-ops WriteOutput analysis.OutputFunc // if nil, output is discarded }
Driver sends compilations sequentially from a queue to an analyzer.
type Queue ¶
type Queue interface { // Next invokes f with the next available compilation in the queue. If no // further values are available, Next must return ErrEndOfQueue; otherwise, // the return value from f is propagated to the caller of Next. Next(_ context.Context, f CompilationFunc) error }
A Queue represents an ordered sequence of compilation units.
Click to show internal directories.
Click to hide internal directories.