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 Deploy(ctx context.Context, module Module, replicas int32, waitForDeployOnline bool, ...) 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 DeployClient
- type Engine
- func (e *Engine) Build(ctx context.Context) error
- func (e *Engine) Close() error
- func (e *Engine) Deploy(ctx context.Context, replicas int32, waitForDeployOnline bool) error
- func (e *Engine) Dev(ctx context.Context, period time.Duration) error
- func (e *Engine) Graph(modules ...string) (map[string][]string, error)
- func (e *Engine) Import(ctx context.Context, schema *schema.Module)
- 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 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
SetPOMProperties updates the ftl.version 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 DeployClient ¶ added in v0.145.4
type DeployClient interface { GetArtefactDiffs(context.Context, *connect.Request[ftlv1.GetArtefactDiffsRequest]) (*connect.Response[ftlv1.GetArtefactDiffsResponse], error) UploadArtefact(context.Context, *connect.Request[ftlv1.UploadArtefactRequest]) (*connect.Response[ftlv1.UploadArtefactResponse], error) CreateDeployment(context.Context, *connect.Request[ftlv1.CreateDeploymentRequest]) (*connect.Response[ftlv1.CreateDeploymentResponse], error) ReplaceDeploy(context.Context, *connect.Request[ftlv1.ReplaceDeployRequest]) (*connect.Response[ftlv1.ReplaceDeployResponse], error) Status(context.Context, *connect.Request[ftlv1.StatusRequest]) (*connect.Response[ftlv1.StatusResponse], error) }
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) Dev ¶ added in v0.142.0
Dev builds and deploys all local modules and watches for changes, redeploying as necessary.
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 }