buildengine

package
v0.146.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

Package buildengine provides a framework for building FTL modules.

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = errors.New("skip directory")

ErrSkip can be returned by the WalkDir callback to skip a file or directory.

Functions

func Build

func Build(ctx context.Context, sch *schema.Schema, module Module) error

Build a module in the given directory given the schema and module config.

func Deploy added in v0.139.0

func Deploy(ctx context.Context, module Module, replicas int32, waitForDeployOnline bool, client DeployClient) error

Deploy a module to the FTL controller with the given number of replicas. Optionally wait for the deployment to become ready.

func DiscoverModules

func DiscoverModules(ctx context.Context, dirs ...string) ([]moduleconfig.ModuleConfig, error)

DiscoverModules recursively loads all modules under the given directories.

If no directories are provided, the current working directory is used.

func SetPOMProperties added in v0.133.1

func SetPOMProperties(ctx context.Context, baseDir string) error

SetPOMProperties updates the ftl.version properties in the pom.xml file in the given base directory.

func TopologicalSort added in v0.134.1

func TopologicalSort(graph map[string][]string) [][]string

TopologicalSort returns a sequence of groups of modules in topological order that may be built in parallel.

func WalkDir

func WalkDir(dir string, fn func(path string, d fs.DirEntry) error) error

WalkDir performs a depth-first walk of the file tree rooted at dir, calling fn for each file or directory in the tree, including dir.

It will adhere to .gitignore files. The callback "fn" can return ErrSkip to skip recursion.

func Watch added in v0.131.0

func Watch(ctx context.Context, period time.Duration, dirs ...string) *pubsub.Topic[WatchEvent]

Watch the given directories for new modules, deleted modules, and changes to existing modules, publishing a change event for each.

Types

type Engine added in v0.134.1

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

Engine for building a set of modules.

func New added in v0.134.1

New constructs a new Engine.

Completely offline builds are possible if the full dependency graph is locally available. If the FTL controller is available, it will be used to pull in missing schemas.

"dirs" are directories to scan for local modules.

func (*Engine) Build added in v0.134.1

func (e *Engine) Build(ctx context.Context) error

Build attempts to build all local modules.

func (*Engine) Close added in v0.134.1

func (e *Engine) Close() error

Close stops the Engine's schema sync.

func (*Engine) Deploy added in v0.139.0

func (e *Engine) Deploy(ctx context.Context, replicas int32, waitForDeployOnline bool) error

Deploy attempts to build and deploy all local modules.

func (*Engine) Dev added in v0.142.0

func (e *Engine) Dev(ctx context.Context, period time.Duration) error

Dev builds and deploys all local modules and watches for changes, redeploying as necessary.

func (*Engine) Graph added in v0.134.1

func (e *Engine) Graph(modules ...string) (map[string][]string, error)

Graph returns the dependency graph for the given modules.

If no modules are provided, the entire graph is returned. An error is returned if any dependencies are missing.

func (*Engine) Import added in v0.134.1

func (e *Engine) Import(ctx context.Context, schema *schema.Module)

Import manually imports a schema for a module as if it were retrieved from the FTL controller.

type FileChangeType added in v0.131.0

type FileChangeType rune
const (
	FileAdded   FileChangeType = '+'
	FileRemoved FileChangeType = '-'
	FileChanged FileChangeType = '*'
)

func CompareFileHashes

func CompareFileHashes(oldFiles, newFiles FileHashes) (FileChangeType, string, bool)

CompareFileHashes compares the hashes of the files in the oldFiles and newFiles maps.

Returns true if the hashes are equal, false otherwise.

If false, the returned string will be a file that caused the difference and the returned FileChangeType will be the type of change that occurred.

func (FileChangeType) GoString added in v0.131.0

func (f FileChangeType) GoString() string

func (FileChangeType) String added in v0.131.0

func (f FileChangeType) String() string

type FileHashes added in v0.131.0

type FileHashes map[string][]byte

func ComputeFileHashes

func ComputeFileHashes(config moduleconfig.ModuleConfig) (FileHashes, error)

ComputeFileHashes computes the SHA256 hash of all (non-git-ignored) files in the given directory.

type Module added in v0.131.0

type Module struct {
	moduleconfig.ModuleConfig
	Dependencies []string
}

A Module is a ModuleConfig with its dependencies populated.

func LoadModule added in v0.133.1

func LoadModule(ctx context.Context, dir string) (Module, error)

LoadModule loads a module from the given directory.

A Module includes the module configuration as well as its dependencies extracted from source code.

func UpdateAllDependencies

func UpdateAllDependencies(ctx context.Context, modules ...moduleconfig.ModuleConfig) ([]Module, error)

UpdateAllDependencies calls UpdateDependencies on each module in the list.

func UpdateDependencies

func UpdateDependencies(ctx context.Context, config moduleconfig.ModuleConfig) (Module, error)

UpdateDependencies finds the dependencies for an FTL module and returns a Module with those dependencies populated.

type WatchEvent added in v0.131.0

type WatchEvent interface {
	// contains filtered or unexported methods
}

A WatchEvent is an event that occurs when a module is added, removed, or changed.

type WatchEventModuleAdded added in v0.131.0

type WatchEventModuleAdded struct{ Module Module }

type WatchEventModuleChanged added in v0.131.0

type WatchEventModuleChanged struct {
	Module Module
	Change FileChangeType
	Path   string
}

type WatchEventModuleRemoved added in v0.131.0

type WatchEventModuleRemoved struct{ Module Module }

Jump to

Keyboard shortcuts

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