Documentation
¶
Overview ¶
Package buildengine provides a framework for building FTL modules.
Index ¶
- Constants
- func CleanStubs(ctx context.Context, projectRoot 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 AdminClient
- type Config
- type DependencyCycleError
- type DependencyGrapher
- type DependencyMode
- type DeployCoordinator
- type Engine
- func (e *Engine) Build(ctx context.Context) error
- func (e *Engine) BuildAndDeploy(ctx context.Context, replicas optional.Option[int32], waitForDeployOnline bool, ...) (err error)
- func (e *Engine) BuildWithCallback(ctx context.Context, ...) error
- func (e *Engine) Close() 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) GetModuleSchema(moduleName string) (*schema.Module, bool)
- func (e *Engine) GetSchema() (*schema.Schema, bool)
- func (e *Engine) Graph(moduleNames ...string) (map[string][]string, error)
- func (e *Engine) Import(ctx context.Context, realmName string, moduleSch *schema.Module)
- func (e *Engine) Modules() []string
- func (e *Engine) StartServices(ctx context.Context) ([]rpc.Option, error)
- type Module
- type Option
- type SchemaUpdatedEvent
Constants ¶
const (
FTLFullSchemaPath = "ftl-full-schema.pb"
)
Variables ¶
This section is empty.
Functions ¶
func CleanStubs ¶
func CleanStubs(ctx context.Context, projectRoot string, configs []moduleconfig.UnvalidatedModuleConfig) error
CleanStubs removes all generated stubs.
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 AdminClient ¶ added in v0.448.0
type AdminClient interface {
ApplyChangeset(ctx context.Context, req *connect.Request[adminpb.ApplyChangesetRequest]) (*connect.ServerStreamForClient[adminpb.ApplyChangesetResponse], error)
ClusterInfo(ctx context.Context, req *connect.Request[adminpb.ClusterInfoRequest]) (*connect.Response[adminpb.ClusterInfoResponse], error)
GetArtefactDiffs(ctx context.Context, req *connect.Request[adminpb.GetArtefactDiffsRequest]) (*connect.Response[adminpb.GetArtefactDiffsResponse], error)
UploadArtefact(ctx context.Context) *connect.ClientStreamForClient[adminpb.UploadArtefactRequest, adminpb.UploadArtefactResponse]
StreamLogs(ctx context.Context, req *connect.Request[adminpb.StreamLogsRequest]) (*connect.ServerStreamForClient[adminpb.StreamLogsResponse], error)
Ping(ctx context.Context, req *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
}
type DependencyCycleError ¶ added in v0.460.0
type DependencyCycleError struct {
Modules []string
}
func (DependencyCycleError) Error ¶ added in v0.460.0
func (e DependencyCycleError) Error() string
type DependencyGrapher ¶ added in v0.462.0
type DependencyMode ¶
type DependencyMode string
DependencyMode is an enum for dependency modes
const ( Raw DependencyMode = "Raw" AlwaysIncludeBuiltin DependencyMode = "AlwaysIncludingBuiltin" )
type DeployCoordinator ¶ added in v0.462.0
type DeployCoordinator struct {
SchemaUpdates chan SchemaUpdatedEvent
// contains filtered or unexported fields
}
DeployCoordinator manages the deployment of modules through changesets. It ensures that changesets are deployed in the correct order and that changesets are not deployed if they are superseded by a newer changeset.
The DeployCoordinator also maintains a schema based on active changesets and queued modules. This allows the build engine to build modules against where the schema is moving to. For example if module A is dependant on module B and module B builds with a breaking schema change deploy coordinator will put deployment of A into a pending state, but publish it as part of the its schema. This allows the build engine to react and build module A against the new schema for module B. The DeployCoordinator will then create a changeset of A and B together.
func NewDeployCoordinator ¶ added in v0.462.0
func NewDeployCoordinator( ctx context.Context, adminClient AdminClient, schemaSource *schemaeventsource.EventSource, dependencyGrapher DependencyGrapher, engineUpdates chan *buildenginepb.EngineEvent, logChanges bool, projectConfig projectconfig.Config, externalRealms *xsync.MapOf[string, *schema.Realm], ) *DeployCoordinator
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine for building a set of modules.
func New ¶
func New( ctx context.Context, adminClient AdminClient, schemaSource *schemaeventsource.EventSource, projectConfig projectconfig.Config, moduleDirs []string, logChanges bool, 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.
"moduleDirs" are directories to scan for local modules.
func (*Engine) BuildAndDeploy ¶
func (e *Engine) BuildAndDeploy(ctx context.Context, replicas optional.Option[int32], waitForDeployOnline bool, singleChangeset bool, moduleNames ...string) (err error)
BuildAndDeploy attempts to build and deploy all local modules.
func (*Engine) BuildWithCallback ¶ added in v0.502.0
func (e *Engine) BuildWithCallback(ctx context.Context, callback func(ctx context.Context, module Module, moduleSch *schema.Module, tmpDeployDir string, deployPaths []string) error) error
BuildWithCallback attempts to build all local modules, and calls back with the result
func (*Engine) Dev ¶
Dev builds and deploys all local modules and watches for changes, redeploying as necessary.
func (*Engine) GetModuleSchema ¶ added in v0.462.0
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.
func (*Engine) Import ¶
Import manually imports a schema for a module as if it were retrieved from the FTL controller.
type Module ¶
type Module struct {
Config moduleconfig.ModuleConfig
// SQLErrors are errors that occurred during SQL build which overrule any errors from the language plugin
SQLError error
// contains filtered or unexported fields
}
Module represents an FTL module in the build engine
func (Module) CopyWithDependencies ¶
func (Module) CopyWithSQLErrors ¶ added in v0.468.2
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
type SchemaUpdatedEvent ¶ added in v0.462.0
type SchemaUpdatedEvent struct {
// contains filtered or unexported fields
}