optimizer

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package optimizer provides pipeline optimization analysis.

Index

Constants

View Source
const (
	SeverityLow      = "low"
	SeverityMedium   = "medium"
	SeverityHigh     = "high"
	SeverityCritical = "critical"
)

Severity levels for optimization suggestions

View Source
const (
	CategoryParallelization = "parallelization"
	CategoryCache           = "cache"
	CategoryTimeout         = "timeout"
	CategoryArtifact        = "artifact"
	CategoryReliability     = "reliability"
	CategoryResource        = "resource"
)

Category types for optimization suggestions

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

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

Analyzer analyzes pipelines for optimization opportunities.

func New

func New() *Analyzer

New creates a new Analyzer with all default rules enabled.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(path string) (*Result, error)

Analyze analyzes a pipeline directory and returns optimization suggestions.

func (*Analyzer) DisableRule

func (a *Analyzer) DisableRule(id string)

DisableRule disables a rule by ID.

func (*Analyzer) EnableRule

func (a *Analyzer) EnableRule(id string)

EnableRule enables a rule by ID.

func (*Analyzer) IsRuleEnabled

func (a *Analyzer) IsRuleEnabled(id string) bool

IsRuleEnabled returns whether a rule is enabled.

func (*Analyzer) SetCategoryFilter

func (a *Analyzer) SetCategoryFilter(category string)

SetCategoryFilter sets a category filter to only analyze specific categories.

func (*Analyzer) SetExpectedTimeout

func (a *Analyzer) SetExpectedTimeout(timeout string)

SetExpectedTimeout sets the expected job duration for timeout recommendations.

type Context

type Context struct {
	Jobs            []discover.DiscoveredJob
	JobMap          map[string]discover.DiscoveredJob
	VarToName       map[string]string
	JobDetails      map[string]*JobDetail
	ExpectedTimeout string
}

Context provides shared context for rules during analysis.

type JobDetail

type JobDetail struct {
	VariableName     string
	HasCache         bool
	HasCacheFallback bool
	HasArtifacts     bool
	HasTimeout       bool
	CacheKeys        []string
	ArtifactExpiry   string
	Timeout          string
	Interruptible    bool
	ScriptLength     int
	HasResourceGroup bool
}

JobDetail contains detailed information about a job extracted from source code.

type Result

type Result struct {
	Success     bool         `json:"success"`
	Suggestions []Suggestion `json:"suggestions,omitempty"`
	JobCount    int          `json:"job_count"`
	Summary     Summary      `json:"summary"`
}

Result represents the result of an optimization analysis.

type Rule

type Rule interface {
	ID() string
	Category() string
	Analyze(ctx *Context) []Suggestion
}

Rule represents an optimization rule.

type Suggestion

type Suggestion struct {
	Category    string `json:"category"`
	Severity    string `json:"severity"`
	Job         string `json:"job,omitempty"`
	Message     string `json:"message"`
	Explanation string `json:"explanation,omitempty"`
	Suggestion  string `json:"suggestion"`
}

Suggestion represents a single optimization suggestion.

type Summary

type Summary struct {
	TotalSuggestions      int            `json:"total_suggestions"`
	SuggestionsByCategory map[string]int `json:"suggestions_by_category"`
	SuggestionsBySeverity map[string]int `json:"suggestions_by_severity"`
}

Summary provides a high-level overview of optimization opportunities.

Jump to

Keyboard shortcuts

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