buildengine

package
v0.133.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 35 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, module Module) error

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

func BuildOrder

func BuildOrder(modules []Module) ([][]Module, error)

BuildOrder returns groups of modules in topological order that can be built in parallel.

func DiscoverModules

func DiscoverModules(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 and ftlEndpoint properties in the pom.xml file in the given base directory.

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 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(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(modules []moduleconfig.ModuleConfig) ([]Module, error)

UpdateAllDependencies calls UpdateDependencies on each module in the list.

func UpdateDependencies

func UpdateDependencies(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