model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DefaultWorkerType is assigned to freshly scaffolded components.

Functions

This section is empty.

Types

type Brick

type Brick struct {
	Name       string
	Kind       Kind
	Dir        string // absolute path to the brick directory
	ImportPath string // <module>/components/<name> or <module>/bases/<name>
	Interface  string // interface (public) package name; defaults to Name
	WorkerType WorkerType

	// Deps holds the names of other bricks this brick imports. It is populated
	// by the deps analysis, not by the loader.
	Deps []string
}

Brick is a component or a base: a reusable building block living under components/<name> or bases/<name>.

func (*Brick) IsComponent

func (b *Brick) IsComponent() bool

IsComponent reports whether the brick is a component.

type Determinism

type Determinism string

Determinism is one axis of a worker type: whether the same inputs and world always yield the same result.

const (
	Deterministic    Determinism = "deterministic"
	NonDeterministic Determinism = "non_deterministic"
)

type Effect

type Effect string

Effect is a single way a worker interacts with the world beyond its declared inputs and outputs.

const (
	InputEffect  Effect = "input_effect"
	OutputEffect Effect = "output_effect"
)

type Effectfulness

type Effectfulness struct {
	Pure    bool
	Effects []Effect
}

Effectfulness is the second axis: either pure, or a non-empty set of effects. It unmarshals from YAML as either the scalar "pure" or a sequence of effects.

func (Effectfulness) HasEffect

func (e Effectfulness) HasEffect(eff Effect) bool

HasEffect reports whether the worker declares the given effect.

func (Effectfulness) IsEffectful

func (e Effectfulness) IsEffectful() bool

IsEffectful reports whether the worker declares any effect.

func (Effectfulness) MarshalYAML

func (e Effectfulness) MarshalYAML() (any, error)

MarshalYAML renders pure as the scalar "pure" and otherwise a list of effects.

func (Effectfulness) String

func (e Effectfulness) String() string

func (*Effectfulness) UnmarshalYAML

func (e *Effectfulness) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts either "pure" (scalar) or a list of effects (sequence).

type Kind

type Kind string

Kind distinguishes the two kinds of brick.

const (
	ComponentKind Kind = "component"
	BaseKind      Kind = "base"
)

type Project

type Project struct {
	Name          string
	Dir           string
	IsDevelopment bool
	Bricks        []string // declared brick names (from project.yaml)
}

Project is a deployable artifact (or the development project) composed of a declared set of bricks.

type TagPatterns

type TagPatterns struct {
	Stable  string
	Release string
}

TagPatterns configures how stable/release points are recognised in the VCS.

type VCS

type VCS struct {
	Name    string
	AutoAdd bool
}

VCS configures version-control behaviour.

type WorkerType

type WorkerType struct {
	Determinism   Determinism   `yaml:"determinism"`
	Effectfulness Effectfulness `yaml:"effectfulness"`
}

WorkerType is the product of the two axes (8 possible values).

func (WorkerType) Merge

func (w WorkerType) Merge(other WorkerType) WorkerType

Merge combines two worker types into the weaker (more permissive) of the two, used to propagate effects/non-determinism through a dependency graph: the result is non-deterministic if either is, and its effects are the union.

func (WorkerType) String

func (w WorkerType) String() string

func (WorkerType) Validate

func (w WorkerType) Validate() error

Validate checks the worker type against the embedded principles vocabulary.

type Workspace

type Workspace struct {
	Root         string
	Module       string
	TopNamespace string
	Components   map[string]*Brick
	Bases        map[string]*Brick
	Projects     map[string]*Project
	TagPatterns  TagPatterns
	VCS          VCS
	Warnings     []string
}

Workspace is the in-memory model of a goforge workspace, built by the loader.

func (*Workspace) Brick

func (w *Workspace) Brick(name string) (*Brick, bool)

Brick returns a brick (component or base) by name.

func (*Workspace) Bricks

func (w *Workspace) Bricks() []*Brick

Bricks returns all bricks sorted: components first (alphabetical), then bases.

func (*Workspace) SortedProjects

func (w *Workspace) SortedProjects() []*Project

SortedProjects returns projects sorted by name, with development last.

Jump to

Keyboard shortcuts

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