Documentation ¶
Overview ¶
Package buildengine provides a framework for building FTL modules.
Index ¶
- func CleanStubs(ctx context.Context, projectRoot string) error
- func Deploy(ctx context.Context, projectConfig projectconfig.Config, module Module, ...) error
- func FindFilesToDeploy(config moduleconfig.AbsModuleConfig, deploy []string) ([]string, error)
- func GenerateStubs(ctx context.Context, projectRoot string, modules []*schema.Module, ...) error
- func SyncStubReferences(ctx context.Context, projectRoot string, moduleNames []string, ...) error
- func TopologicalSort(graph map[string][]string) (groups [][]string, cycleError error)
- type DependencyMode
- type DeployClient
- type Engine
- func (e *Engine) Build(ctx context.Context) error
- func (e *Engine) BuildAndDeploy(ctx context.Context, replicas int32, waitForDeployOnline bool, ...) 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) Each(fn func(Module) error) (err error)
- func (e *Engine) Graph(moduleNames ...string) (map[string][]string, error)
- func (e *Engine) Import(ctx context.Context, schema *schema.Module)
- func (e *Engine) Modules() []string
- type Module
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanStubs ¶
CleanStubs removes all generated stubs.
func Deploy ¶
func Deploy(ctx context.Context, projectConfig projectconfig.Config, module Module, deploy []string, 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 FindFilesToDeploy ¶
func FindFilesToDeploy(config moduleconfig.AbsModuleConfig, deploy []string) ([]string, error)
FindFilesToDeploy returns a list of files to deploy for the given module.
func GenerateStubs ¶
func GenerateStubs(ctx context.Context, projectRoot string, modules []*schema.Module, metas map[string]moduleMeta) error
GenerateStubs generates stubs for the given modules.
Currently, only Go stubs are supported. Kotlin and other language stubs can be added in the future.
func SyncStubReferences ¶
func SyncStubReferences(ctx context.Context, projectRoot string, moduleNames []string, metas map[string]moduleMeta, view *schema.Schema) error
SyncStubReferences syncs the references in the generated stubs.
For Go, this means updating all the go.work files to include all known modules in the shared stubbed modules directory.
func TopologicalSort ¶
TopologicalSort attempts to order the modules supplied in the graph based on their topologically sorted order. A cycle in the module dependency graph will cause this sort to be incomplete. The sorted modules are returned as a sequence of `groups` of modules that may be built in parallel. The `unsorted` modules impacted by a dependency cycle get reported as an error.
Types ¶
type DependencyMode ¶
type DependencyMode string
DependencyMode is an enum for dependency modes
const ( Raw DependencyMode = "Raw" AlwaysIncludeBuiltin DependencyMode = "AlwaysIncludingBuiltin" )
type DeployClient ¶
type DeployClient interface { GetArtefactDiffs(ctx context.Context, req *connect.Request[ftlv1.GetArtefactDiffsRequest]) (*connect.Response[ftlv1.GetArtefactDiffsResponse], error) UploadArtefact(ctx context.Context, req *connect.Request[ftlv1.UploadArtefactRequest]) (*connect.Response[ftlv1.UploadArtefactResponse], error) CreateDeployment(ctx context.Context, req *connect.Request[ftlv1.CreateDeploymentRequest]) (*connect.Response[ftlv1.CreateDeploymentResponse], error) ReplaceDeploy(ctx context.Context, req *connect.Request[ftlv1.ReplaceDeployRequest]) (*connect.Response[ftlv1.ReplaceDeployResponse], error) Status(ctx context.Context, req *connect.Request[ftlv1.StatusRequest]) (*connect.Response[ftlv1.StatusResponse], error) UpdateDeploy(ctx context.Context, req *connect.Request[ftlv1.UpdateDeployRequest]) (*connect.Response[ftlv1.UpdateDeployResponse], error) Ping(ctx context.Context, req *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error) }
type Engine ¶
type Engine struct { // topic to subscribe to engine events EngineUpdates *pubsub.Topic[*buildenginepb.EngineEvent] // contains filtered or unexported fields }
Engine for building a set of modules.
func New ¶
func New( ctx context.Context, client DeployClient, schemaSource schemaeventsource.EventSource, projectConfig projectconfig.Config, moduleDirs []string, updatesEndpoint *url.URL, options ...Option, ) (*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) BuildAndDeploy ¶
func (e *Engine) BuildAndDeploy(ctx context.Context, replicas int32, waitForDeployOnline bool, moduleNames ...string) error
BuildAndDeploy attempts to build and deploy all local modules.
func (*Engine) Deploy ¶
Deploy attempts to deploy all (already compiled) local modules.
If waitForDeployOnline is true, this function will block until all deployments are online.
func (*Engine) Dev ¶
Dev builds and deploys all local modules and watches for changes, redeploying as necessary.
func (*Engine) Graph ¶
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.
type Module ¶
type Module struct { Config moduleconfig.ModuleConfig // paths to deploy, relative to ModuleConfig.DeployDir Deploy []string // contains filtered or unexported fields }
Module represents an FTL module in the build engine
func (Module) CopyWithDependencies ¶
func (Module) CopyWithDeploy ¶
func (Module) Dependencies ¶
func (m Module) Dependencies(mode DependencyMode) []string
Dependencies returns the dependencies of the module Mode allows us to control how dependencies are returned.
When calling language plugins, use Raw mode to ensure plugins receive the same dependencies that were declared.
type Option ¶
type Option func(o *Engine)
func Parallelism ¶
func WithDevMode ¶
func WithDevMode(updates chan dev.LocalEndpoint) Option
WithDevMode sets the engine to dev mode.
func WithStartTime ¶
WithStartTime sets the start time to report total startup time