Documentation
¶
Overview ¶
Package buildengine provides a framework for building FTL modules.
Index ¶
- Variables
- func Build(ctx context.Context, sch *schema.Schema, module Module) error
- func DiscoverModules(ctx context.Context, dirs ...string) ([]moduleconfig.ModuleConfig, error)
- func SetPOMProperties(ctx context.Context, baseDir string) error
- func TopologicalSort(graph map[string][]string) [][]string
- func WalkDir(dir string, fn func(path string, d fs.DirEntry) error) error
- func Watch(ctx context.Context, period time.Duration, dirs ...string) *pubsub.Topic[WatchEvent]
- type Engine
- type FileChangeType
- type FileHashes
- type Module
- type WatchEvent
- type WatchEventModuleAdded
- type WatchEventModuleChanged
- type WatchEventModuleRemoved
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("skip directory")
ErrSkip can be returned by the WalkDir callback to skip a file or directory.
Functions ¶
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
SetPOMProperties updates the ftl.version and ftlEndpoint properties in the pom.xml file in the given base directory.
func TopologicalSort ¶ added in v0.134.1
TopologicalSort returns a sequence of groups of modules in topological order that may be built in parallel.
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
func New(ctx context.Context, client ftlv1connect.ControllerServiceClient, dirs ...string) (*Engine, error)
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
Build attempts to build the specified modules, or all local modules if none are provided.
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
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
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 }