languageplugin

package
v0.386.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const BuildLockTimeout = time.Minute
View Source
const JavaBuildToolGradle string = "gradle"
View Source
const JavaBuildToolMaven string = "maven"

Variables

This section is empty.

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
}

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
}

type CompilerBuildError

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

func (CompilerBuildError) Error

func (e CompilerBuildError) Error() string

func (CompilerBuildError) Unwrap

func (e CompilerBuildError) Unwrap() error

type JavaConfig

type JavaConfig struct {
	BuildTool string `mapstructure:"build-tool"`
}

type LanguagePlugin

type LanguagePlugin interface {
	// Updates topic for all update events from the plugin
	// The same topic must be returned each time this method is called
	Updates() *pubsub.Topic[PluginEvent]

	// 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.
	ModuleConfigDefaults(ctx context.Context, dir string) (moduleconfig.CustomDefaults, error)

	// GetCreateModuleFlags returns the flags that can be used to create a module for this language.
	GetCreateModuleFlags(ctx context.Context) ([]*kong.Flag, error)

	// CreateModule creates a new module in the given directory with the given name and language.
	CreateModule(ctx context.Context, projConfig projectconfig.Config, moduleConfig moduleconfig.ModuleConfig, flags map[string]string) error

	// GetDependencies returns the dependencies of the module.
	GetDependencies(ctx context.Context, moduleConfig moduleconfig.ModuleConfig) ([]string, 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().
	Build(ctx context.Context, projectRoot, stubsRoot string, bctx BuildContext, buildEnv []string, rebuildAutomatically bool) (BuildResult, error)

	// Generate stubs for the given module.
	GenerateStubs(ctx context.Context, dir string, module *schema.Module, moduleConfig moduleconfig.ModuleConfig, nativeModuleConfig optional.Option[moduleconfig.ModuleConfig]) 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.
	SyncStubReferences(ctx context.Context, config moduleconfig.ModuleConfig, dir string, moduleNames []string) error

	// Kill stops the plugin and cleans up any resources.
	Kill() error
}

LanguagePlugin handles building and scaffolding modules in a specific language.

func New

func New(ctx context.Context, bindAllocator *bind.BindAllocator, language string) (p LanguagePlugin, err error)

PluginFromConfig creates a new language plugin from the given config.

type PluginEvent

type PluginEvent interface {
	ModuleName() string
	// 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