buildengine

package
v0.393.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package buildengine provides a framework for building FTL modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanStubs

func CleanStubs(ctx context.Context, projectRoot string) error

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) 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

func TopologicalSort(graph map[string][]string) (groups [][]string, cycleError error)

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 added in v0.386.0

type DependencyMode string

DependencyMode is an enum for dependency modes

const (
	Raw                  DependencyMode = "Raw"
	AlwaysIncludeBuiltin DependencyMode = "AlwaysIncludingBuiltin"
)

type Engine

type Engine struct {

	// topic to subscribe to engine events
	EngineUpdates *pubsub.Topic[EngineEvent]
	// contains filtered or unexported fields
}

Engine for building a set of modules.

func New

func New(ctx context.Context, client DeployClient, projectConfig projectconfig.Config, moduleDirs []string, bindAllocator *bind.BindAllocator, 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) Build

func (e *Engine) Build(ctx context.Context) error

Build attempts to build all 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) Close

func (e *Engine) Close() error

Close stops the Engine's schema sync.

func (*Engine) Deploy

func (e *Engine) Deploy(ctx context.Context, replicas int32, waitForDeployOnline bool) error

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

func (e *Engine) Dev(ctx context.Context, period time.Duration) error

Dev builds and deploys all local modules and watches for changes, redeploying as necessary.

func (*Engine) Each

func (e *Engine) Each(fn func(Module) error) (err error)

Each iterates over all local modules.

func (*Engine) Graph

func (e *Engine) Graph(moduleNames ...string) (map[string][]string, error)

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

func (e *Engine) Import(ctx context.Context, schema *schema.Module)

Import manually imports a schema for a module as if it were retrieved from the FTL controller.

func (*Engine) Modules

func (e *Engine) Modules() []string

Modules returns the names of all modules.

type EngineEnded added in v0.387.1

type EngineEnded struct {
	ModuleErrors map[string]error
}

EngineEnded is published when the engine is no longer building or deploying any modules. If there are any remaining errors, they will be included in the ModuleErrors map.

For individual events as each module build ends, see ModuleBuildSuccess and ModuleBuildFailed

type EngineEvent added in v0.387.1

type EngineEvent interface {
	// contains filtered or unexported methods
}

EngineEvent is an event published by the engine as modules get built and deployed.

type EngineStarted added in v0.387.1

type EngineStarted struct{}

EngineStarted is published when the engine becomes busy building and deploying modules.

For individual events as each module build starts, see ModuleBuildStarted

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 (m Module) CopyWithDependencies(dependencies []string) Module

func (Module) CopyWithDeploy added in v0.377.0

func (m Module) CopyWithDeploy(files []string) Module

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 ModuleAdded added in v0.387.1

type ModuleAdded struct {
	Module string
}

ModuleAdded is published when the engine discovers a module.

type ModuleBuildFailed added in v0.387.1

type ModuleBuildFailed struct {
	Config        moduleconfig.ModuleConfig
	Error         error
	IsAutoRebuild bool
}

ModuleBuildFailed is published for any build failures.

type ModuleBuildStarted added in v0.387.1

type ModuleBuildStarted struct {
	Config        moduleconfig.ModuleConfig
	IsAutoRebuild bool
}

ModuleBuildStarted is published when a build has started for a module.

type ModuleBuildSuccess added in v0.387.1

type ModuleBuildSuccess struct {
	Config        moduleconfig.ModuleConfig
	IsAutoRebuild bool
}

ModuleBuildSuccess is published when all modules have been built successfully built.

type ModuleBuildWaiting added in v0.387.1

type ModuleBuildWaiting struct {
	Config moduleconfig.ModuleConfig
}

ModuleBuildWaiting is published when a build is waiting for dependencies to build

type ModuleDeployFailed added in v0.387.1

type ModuleDeployFailed struct {
	Module string
	Error  error
}

ModuleDeployFailed is published for any deploy failures.

type ModuleDeployStarted added in v0.387.1

type ModuleDeployStarted struct {
	Module string
}

ModuleDeployStarted is published when a deploy has begun for a module.

type ModuleDeploySuccess added in v0.387.1

type ModuleDeploySuccess struct {
	Module string
}

ModuleDeploySuccess is published when all modules have been built successfully deployed.

type ModuleRemoved added in v0.387.1

type ModuleRemoved struct {
	Module string
}

ModuleRemoved is published when the engine discovers a module has been removed.

type Option

type Option func(o *Engine)

func BuildEnv added in v0.361.0

func BuildEnv(env []string) Option

func Parallelism

func Parallelism(n int) Option

func WithDevMode added in v0.367.0

func WithDevMode(devMode bool) Option

WithDevMode sets the engine to dev mode.

func WithStartTime added in v0.370.0

func WithStartTime(startTime time.Time) Option

WithStartTime sets the start time to report total startup time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL