engine

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULTPARALLEL = 12

Variables

This section is empty.

Functions

func ExecuteJob

func ExecuteJob(ctx context.Context, cfg ExecuteJobConfig) error

ExecuteJ

Types

type Dependency

type Dependency struct {
	Job      string   `json:"job"`
	Requires []string `json:"requires,omitempty"`
}

type ExecuteJobConfig

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

type Executor

type Executor struct {
	MaxParallel int

	Runner        runner.Runner
	Checkouter    checkout.Checkouter
	ArtifactStore artifact.Store
	LogsStore     logs.Store
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(cfg ExecutorConfig) *Executor

func (*Executor) Shutdown

func (e *Executor) Shutdown()

func (*Executor) Submit

func (e *Executor) Submit(ctx context.Context, id string, p *Pipeline) (*PipelineRuntime, error)

Submit validates a pipeline, then adds a pipeline to worker queue. Returns ValidationErrors if validation fails

type ExecutorConfig

type ExecutorConfig struct {
	// MaxParallel should be set to -1 for automatic detection
	MaxParallel int

	Runner        runner.Runner
	ArtifactStore artifact.Store
	Checkouter    checkout.Checkouter
	LogsStore     logs.Store
}

type GitHub

type GitHub struct {
	Push    *PushConfig    `json:"push,omitempty"`
	Release *ReleaseConfig `json:"release,omitempty"`
}

type Job

type Job struct {
	Name      string              `json:"name"`
	Image     string              `json:"image"`
	Steps     []Step              `json:"steps"`
	DependsOn []Dependency        `json:"depends_on"`
	Env       map[string]string   `json:"env"`
	Artifacts []artifact.Artifact `json:"artifacts,omitempty"`
}

type JobResult

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

type Pipeline

type Pipeline struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Visibility  string            `json:"visibility,omitempty"`
	Checkout    checkout.Checkout `json:"checkout"`
	Jobs        []Job             `json:"jobs"`
	GitHub      *GitHub           `json:"github,omitempty"`
}

func ProcessJSON

func ProcessJSON(data string) (*Pipeline, error)

func ProcessJSONFile

func ProcessJSONFile(path string) (*Pipeline, error)

func (*Pipeline) LookupArtifact

func (p *Pipeline) LookupArtifact(jobName, artifactName string) (artifact.Artifact, error)

func (*Pipeline) Validate

func (p *Pipeline) Validate() error

type PipelineRuntime

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

PipelineRuntime is a state machine that asynchronously tracks the status of a job in a pipeline while it is running. It is safe to wait on by multiple goroutines

PipelineRuntime is not meant to be mutated, use getters.

func (*PipelineRuntime) Done

func (pe *PipelineRuntime) Done() <-chan struct{}

func (*PipelineRuntime) ID

func (pe *PipelineRuntime) ID() string

ID returns the ID associaated with the PipelineRuntime

func (*PipelineRuntime) Pipeline

func (pe *PipelineRuntime) Pipeline() *Pipeline

Pipeline returns the Pipeline associated with the PipelineRuntime

func (*PipelineRuntime) Stop

func (pe *PipelineRuntime) Stop()

func (*PipelineRuntime) Wait

func (pe *PipelineRuntime) Wait() error

type PushConfig

type PushConfig struct {
	Branches []string `json:"branches,omitempty"`
	Tags     []string `json:"tags,omitempty"`
}

type ReleaseArtifact

type ReleaseArtifact struct {
	Job  string `json:"job"`
	Name string `json:"name"`
	As   string `json:"as,omitempty"`
}

type ReleaseConfig

type ReleaseConfig struct {
	On        string            `json:"on"`
	Artifacts []ReleaseArtifact `json:"artifacts"`
}

type Scheduler

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

Scheduler is responsible for bookeeping of Jobs in a pipeline. It stores standard bookeeping data for Topological sort using Kahn's algorithm

Note: Not safe for concurrent use. It must be driven from single goroutine

Internally: we use Kahn's Algorithm to schedule jobs in a pipeline based on dependencies. We execute all parent jobs (on which other jobs depend on) and then execute the next set of dependent processes and so on until all of them execute completely or return an error.

func NewScheduler

func NewScheduler(p *Pipeline) *Scheduler

NewScheduler Creates a new instance of a Scheduler and populates it with the jobs and their dependencies from a **validated** pipeline p.

func (*Scheduler) Complete

func (s *Scheduler) Complete(jobName string) []*Job

Complete marks a jobName as complete and returns the next set of child Jobs that can be processed immediately

func (*Scheduler) Done

func (s *Scheduler) Done() bool

Done returns whether all jobs in the pipeline have finished executing.

func (*Scheduler) Fail

func (s *Scheduler) Fail(jobName string)

Fail marks the jobName as processes but prevents any child jobs from becoming ready

func (*Scheduler) Ready

func (s *Scheduler) Ready() []*Job

Ready returns all available jobs ready to be executed now. (ie. Jobs with indegree = 0)

Note: Ready should only be called once.

type Step

type Step struct {
	Name string `json:"name"`
	Cmd  string `json:"cmd"`
}

type ValidationError

type ValidationError struct {
	Location string
	Message  string
}

func (ValidationError) String

func (v ValidationError) String() string

String generates the error string for a validation error

type ValidationErrors

type ValidationErrors struct {
	Errors []ValidationError
}

func (*ValidationErrors) Add

func (e *ValidationErrors) Add(err ValidationError)

Add appends a ValidationError to ValidationErrors.Errors

func (ValidationErrors) Error

func (e ValidationErrors) Error() string

Error generates the error string summary for all validation errors

It returns a bulleted list.

type WorkItem

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

Jump to

Keyboard shortcuts

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