builder

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoWorkers           = errors.New("builder: no workers")
	ErrBuilderNoJobs       = errors.New("builder: no jobs to run")
	ErrBuilderInvalidState = errors.New("builder: invalid state")
)

Functions

This section is empty.

Types

type BuildState

type BuildState int
const (
	Setup   BuildState = iota // pre-running state. jobs can still be enqueued and config can be changed
	Running                   // the Builder is running. No new jobs can be queued
	Stopped                   // the builder was stopped without any errors
	Err                       // the builder encountered and error
)

type Builder

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

The Builder struct manages the entire multi-goroutine build process. It starts the worker routines, distributes the BuildJobs, and gathers the BuildResults and BuildErrors.

func NewBuilder

func NewBuilder(worker uint) (Builder, error)

Generate a new Builder struct with a configuration.

func (*Builder) AddJob

func (b *Builder) AddJob(job Job) error

Add a new job to the build queue, as long as the builder is till in the Setup state.

func (*Builder) Errors

func (b *Builder) Errors() ([]Error, error)

Retrieve the BuildResults from the finished builder. If the builder is in an invalid state, return error.

func (*Builder) Results

func (b *Builder) Results() ([]Result, error)

Retrieve the BuildResults from the finished builder. If the builder is in an invalid state, return error.

func (*Builder) Run

func (b *Builder) Run() error

Start execution of the builder. The builder will be set into the Running state and will block all methods modifying the Builders stats.

func (*Builder) SetLogger

func (b *Builder) SetLogger(logger *log.Logger)

Provide a custom logger for the builder. By default, the logger will be turned off.

type Error

type Error struct {
	Job Job    // copy of the original build job
	Err string // error message encountered during build
}

When the build of a command fails, a Error is emitted.

func (*Error) Error

func (b *Error) Error() string

Implement error interface over BuildError

func (*Error) String

func (b *Error) String() string

type Job

type Job struct {
	GoPkgPath string // the path to the go package that is build
	Compiler  string // compiler used to build the pkg, probably go or tinygo. TODO: refactor to enum
	Command   string // complete build command issues by builder
	// contains filtered or unexported fields
}

Job defines a job that can be scheduled by the Builder and executed by the work function. It has all necessary information to execute the build and gather error logs.

func NewJob

func NewJob(goPkgPath string, compiler string, buildDir *string) (Job, error)

Generate a new BuildJob structure and verify all provided data. If the path to the goPkg is invalid, it will return an error. TODO: should we enforce that?

type Result

type Result struct {
	Job        Job           // copy of the original build job
	BuildTime  time.Duration // time it took to build the pkg
	BinarySize uint64        // size of the binary in bytes
}

Build result captures information about the build that later can be used for statistics that can be gathered after the build. BuildResults are always valid and do not contain any error information. If errors are encountered during the build process, a BuildError is returned.

Jump to

Keyboard shortcuts

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