Documentation
¶
Index ¶
- Constants
- Variables
- func GetModuleConfigDefaults(ctx context.Context, language string, dir string) (moduleconfig.CustomDefaults, error)
- func GetNewModuleFlags(ctx context.Context, language string) ([]*kong.Flag, error)
- func GetSQLInterfaces(ctx context.Context, config moduleconfig.AbsModuleConfig) (map[string]string, error)
- func NewModule(ctx context.Context, language string, projConfig projectconfig.Config, ...) error
- func PrepareNewCmd(ctx context.Context, projectConfig projectconfig.Config, k *kong.Kong, ...) error
- type AutoRebuildEndedEvent
- type AutoRebuildStartedEvent
- type BuildContext
- type BuildResult
- type LanguagePlugin
- func (p *LanguagePlugin) Build(ctx context.Context, projectConfig projectconfig.Config, stubsRoot string, ...) (BuildResult, error)
- func (p *LanguagePlugin) GenerateStubs(ctx context.Context, dir string, module *schema.Module, ...) error
- func (p *LanguagePlugin) GetDependencies(ctx context.Context, config moduleconfig.ModuleConfig) ([]string, error)
- func (p *LanguagePlugin) Kill() error
- func (p *LanguagePlugin) SyncStubReferences(ctx context.Context, config moduleconfig.ModuleConfig, dir string, ...) error
- func (p *LanguagePlugin) Updates() *pubsub.Topic[PluginEvent]
- type PluginBuildEvent
- type PluginDiedEvent
- type PluginEvent
Constants ¶
const BuildLockTimeout = time.Minute
Variables ¶
var ErrPluginNotRunning = errors.New("language plugin no longer running")
Functions ¶
func GetModuleConfigDefaults ¶ added in v0.471.0
func GetModuleConfigDefaults(ctx context.Context, language string, dir string) (moduleconfig.CustomDefaults, error)
GetModuleConfigDefaults provides custom defaults for the module config.
The result may be cached by FTL, so defaulting logic should not be changing due to normal module changes. For example, it is valid to return defaults based on which build tool is configured within the module directory, as that is not expected to change during normal operation. It is not recommended to read the module's toml file to determine defaults, as when the toml file is updated, the module defaults will not be recalculated.
func GetNewModuleFlags ¶ added in v0.471.0
GetNewModuleFlags returns the flags that can be used to create a module for this language.
func GetSQLInterfaces ¶ added in v0.478.0
func GetSQLInterfaces(ctx context.Context, config moduleconfig.AbsModuleConfig) (map[string]string, error)
func NewModule ¶ added in v0.471.0
func NewModule(ctx context.Context, language string, projConfig projectconfig.Config, moduleConfig moduleconfig.ModuleConfig, flags map[string]string) error
NewModule creates a new module in the given directory with the given name and language.
func PrepareNewCmd ¶ added in v0.420.1
func PrepareNewCmd(ctx context.Context, projectConfig projectconfig.Config, k *kong.Kong, args []string) error
PrepareNewCmd adds language specific flags to kong This allows the new command to have good support for language specific flags like: - help text (ftl module new go --help) - default values - environment variable overrides
Language plugins take time to launch, so we return the one we created so it can be reused in Run().
Types ¶
type AutoRebuildEndedEvent ¶
type AutoRebuildEndedEvent struct {
Module string
Result result.Result[BuildResult]
}
AutoRebuildEndedEvent is sent when the plugin ends an automatic rebuild.
func (AutoRebuildEndedEvent) ModuleName ¶
func (e AutoRebuildEndedEvent) ModuleName() string
type AutoRebuildStartedEvent ¶
type AutoRebuildStartedEvent struct {
Module string
}
AutoRebuildStartedEvent is sent when the plugin starts an automatic rebuild.
func (AutoRebuildStartedEvent) ModuleName ¶
func (e AutoRebuildStartedEvent) ModuleName() string
type BuildContext ¶
type BuildContext struct {
Config moduleconfig.ModuleConfig
Schema *schema.Schema
Dependencies []string
BuildEnv []string
Os string
Arch string
}
BuildContext contains contextual information needed to build.
Any change to the build context would require a new build.
type BuildResult ¶
type BuildResult struct {
StartTime time.Time
Schema *schema.Module
Errors []builderrors.Error
// Files to deploy, relative to the module config's DeployDir
Deploy []string
// Whether the module needs to recalculate its dependencies
InvalidateDependencies bool
// Endpoint of an instance started by the plugin to use in dev mode
DevEndpoint optional.Option[string]
// File that the runner can use to pass info into the hot reload endpoint
HotReloadEndpoint optional.Option[string]
HotReloadVersion optional.Option[int64]
DebugPort int
// contains filtered or unexported fields
}
type LanguagePlugin ¶
type LanguagePlugin struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, dir, language, name string) (p *LanguagePlugin, err error)
New creates a new language plugin from the given config.
func (*LanguagePlugin) Build ¶
func (p *LanguagePlugin) Build(ctx context.Context, projectConfig projectconfig.Config, stubsRoot string, bctx BuildContext, rebuildAutomatically bool) (BuildResult, error)
Build builds the module with the latest config and schema. In dev mode, plugin is responsible for automatically rebuilding as relevant files within the module change, and publishing these automatic builds updates to Updates().
func (*LanguagePlugin) GenerateStubs ¶
func (p *LanguagePlugin) GenerateStubs(ctx context.Context, dir string, module *schema.Module, moduleConfig moduleconfig.ModuleConfig, nativeModuleConfig optional.Option[moduleconfig.ModuleConfig]) error
GenerateStubs for the given module.
func (*LanguagePlugin) GetDependencies ¶
func (p *LanguagePlugin) GetDependencies(ctx context.Context, config moduleconfig.ModuleConfig) ([]string, error)
GetDependencies returns the dependencies of the module.
func (*LanguagePlugin) Kill ¶
func (p *LanguagePlugin) Kill() error
Kill stops the plugin and cleans up any resources.
func (*LanguagePlugin) SyncStubReferences ¶
func (p *LanguagePlugin) SyncStubReferences(ctx context.Context, config moduleconfig.ModuleConfig, dir string, moduleNames []string, view *schema.Schema) error
SyncStubReferences is called when module stubs have been updated. This allows the plugin to update references to external modules, regardless of whether they are dependencies.
For example, go plugin adds references to all modules into the go.work file so that tools can automatically import the modules when users start reference them.
It is optional to do anything with this call.
func (*LanguagePlugin) Updates ¶
func (p *LanguagePlugin) Updates() *pubsub.Topic[PluginEvent]
Updates topic for all update events from the plugin The same topic must be returned each time this method is called
type PluginBuildEvent ¶
type PluginBuildEvent interface {
PluginEvent
ModuleName() string
}
type PluginDiedEvent ¶
type PluginDiedEvent struct {
// Plugins do not always have an associated module name, so we include the module
Plugin *LanguagePlugin
Error error
}
PluginDiedEvent is sent when the plugin dies.
type PluginEvent ¶
type PluginEvent interface {
// contains filtered or unexported methods
}
PluginEvent is used to notify of updates from the plugin.