languageplugin

package
v0.411.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const BuildLockTimeout = time.Minute

Variables

View Source
var ErrPluginNotRunning = errors.New("language plugin no longer running")

Functions

This section is empty.

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

type BuildContext struct {
	Config       moduleconfig.ModuleConfig
	Schema       *schema.Schema
	Dependencies []string
	BuildEnv     []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
	DevRunnerInfoFile optional.Option[string]

	DebugPort int
}

type LanguagePlugin

type LanguagePlugin struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, dir, language, name string, devMode bool) (p *LanguagePlugin, err error)

PluginFromConfig creates a new language plugin from the given config.

func (*LanguagePlugin) Build

func (p *LanguagePlugin) Build(ctx context.Context, projectRoot, 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) CreateModule

func (p *LanguagePlugin) CreateModule(ctx context.Context, projConfig projectconfig.Config, moduleConfig moduleconfig.ModuleConfig, flags map[string]string) error

CreateModule creates a new module in the given directory with the given name and language.

func (*LanguagePlugin) GenerateStubs added in v0.386.0

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

func (p *LanguagePlugin) GetCreateModuleFlags(ctx context.Context) ([]*kong.Flag, error)

GetCreateModuleFlags returns the flags that can be used to create a module for this language.

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

func (p *LanguagePlugin) ModuleConfigDefaults(ctx context.Context, dir string) (moduleconfig.CustomDefaults, error)

ModuleConfigDefaults 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 (*LanguagePlugin) SyncStubReferences added in v0.386.0

func (p *LanguagePlugin) SyncStubReferences(ctx context.Context, config moduleconfig.ModuleConfig, dir string, moduleNames []string) 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 added in v0.387.1

type PluginBuildEvent interface {
	PluginEvent
	ModuleName() string
}

type PluginDiedEvent added in v0.387.1

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.

Jump to

Keyboard shortcuts

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