provisioner

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: 45 Imported by: 0

README

FTL Provisioner

FTL Provisioner will be responsible for creating any infrastructure required by deployments, as well as orchestrating deployments, and keeping track of the state of the underlying infrastructure.

This is still a WIP and should not be used yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvisionMySQLForTest added in v0.399.0

func ProvisionMySQLForTest(ctx context.Context, moduleName string, id string) (string, error)

func ProvisionPostgresForTest added in v0.399.0

func ProvisionPostgresForTest(ctx context.Context, moduleName string, id string) (string, error)

func RunMySQLMigration added in v0.399.0

func RunMySQLMigration(ctx context.Context, dsn string, moduleDir string, name string) error

func RunPostgresMigration added in v0.399.0

func RunPostgresMigration(ctx context.Context, dsn string, moduleDir string, name string) error

func Start

func Start(
	ctx context.Context,
	config Config,
	registry *ProvisionerRegistry,
	controllerClient ftlv1connect.ControllerServiceClient,
) error

Start the Provisioner. Blocks until the context is cancelled.

Types

type CommonProvisionerConfig added in v0.376.0

type CommonProvisionerConfig struct {
	PluginConfigFile *os.File `name:"provisioner-plugin-config" help:"Path to the plugin configuration file." env:"FTL_PROVISIONER_PLUGIN_CONFIG_FILE"`
}

CommonProvisionerConfig is shared config between the production controller and development server.

type Config

type Config struct {
	Bind               *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8893" env:"FTL_BIND"`
	ControllerEndpoint *url.URL `name:"ftl-endpoint" help:"Controller endpoint." env:"FTL_ENDPOINT" default:"http://127.0.0.1:8892"`
	CommonProvisionerConfig
}

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type Deployment added in v0.377.0

type Deployment struct {
	Tasks []*Task
	// TODO: Merge runtimes at creation time
	Module   *schema.Module
	Previous *schema.Module
}

Deployment is a single deployment of resources for a single module

func (*Deployment) Progress added in v0.377.0

func (d *Deployment) Progress(ctx context.Context) (bool, error)

Progress the deployment. Returns true if there are still tasks running or pending.

func (*Deployment) State added in v0.377.0

func (d *Deployment) State() *DeploymentState

type DeploymentState added in v0.377.0

type DeploymentState struct {
	Pending []*Task
	Running *Task
	Failed  *Task
	Done    []*Task
}

type InMemProvisioner added in v0.377.0

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

InMemProvisioner for running an in memory provisioner, constructing all resources concurrently

It spawns a separate goroutine for each resource to be provisioned, and finishes the task when all resources are provisioned or an error occurs.

func NewControllerProvisioner added in v0.377.0

func NewControllerProvisioner(client ftlv1connect.ControllerServiceClient) *InMemProvisioner

NewControllerProvisioner creates a new provisioner that uses the FTL controller to provision modules

func NewDevProvisioner added in v0.377.0

func NewDevProvisioner(postgresPort int, mysqlPort int, recreate bool) *InMemProvisioner

NewDevProvisioner creates a new provisioner that provisions resources locally when running FTL in dev mode

func NewEmbeddedProvisioner added in v0.377.0

func NewEmbeddedProvisioner(handlers map[schema.ResourceType]InMemResourceProvisionerFn) *InMemProvisioner

func NewRunnerScalingProvisioner added in v0.408.0

func NewRunnerScalingProvisioner(runners scaling.RunnerScaling) *InMemProvisioner

func NewSQLMigrationProvisioner added in v0.399.0

func NewSQLMigrationProvisioner(storage *artefacts.OCIArtefactService) *InMemProvisioner

NewSQLMigrationProvisioner creates a new provisioner that provisions database migrations

func (*InMemProvisioner) Ping added in v0.377.0

func (*InMemProvisioner) Provision added in v0.377.0

func (*InMemProvisioner) Status added in v0.377.0

type InMemResourceProvisionerFn added in v0.377.0

type InMemResourceProvisionerFn func(ctx context.Context, module string, resource schema.Provisioned) (*RuntimeEvent, error)

type NoopProvisioner added in v0.377.0

type NoopProvisioner struct{}

NoopProvisioner is a provisioner that does nothing

func (*NoopProvisioner) Ping added in v0.377.0

func (*NoopProvisioner) Provision added in v0.377.0

func (*NoopProvisioner) Status added in v0.377.0

type ProvisionerBinding added in v0.377.0

type ProvisionerBinding struct {
	Provisioner provisionerconnect.ProvisionerPluginServiceClient
	ID          string
	Types       []schema.ResourceType
}

ProvisionerBinding is a Provisioner and the types it supports

func (ProvisionerBinding) String added in v0.388.0

func (p ProvisionerBinding) String() string

type ProvisionerRegistry added in v0.377.0

type ProvisionerRegistry struct {
	Bindings []*ProvisionerBinding
}

ProvisionerRegistry contains all known resource handlers in the order they should be executed

func RegistryFromConfigFile added in v0.377.0

func RegistryFromConfigFile(ctx context.Context, file *os.File, controller ftlv1connect.ControllerServiceClient, scaling scaling.RunnerScaling) (*ProvisionerRegistry, error)

func (*ProvisionerRegistry) CreateDeployment added in v0.377.0

func (reg *ProvisionerRegistry) CreateDeployment(ctx context.Context, desiredModule, existingModule *schema.Module) *Deployment

CreateDeployment to take the system to the desired state

func (*ProvisionerRegistry) Register added in v0.377.0

Register to the registry, to be executed after all the previously added handlers

type RuntimeEvent added in v0.410.0

type RuntimeEvent struct {
	Module   schema.ModuleRuntimeEvent
	Database *schema.DatabaseRuntimeEvent
	Topic    *schema.TopicRuntimeEvent
	Verb     *schema.VerbRuntimeEvent
}

RuntimeEvent is a union type of all runtime events TODO: Remove once we have fully typed provisioners

type Service

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

func New

func New(
	ctx context.Context,
	config Config,
	controllerClient ftlv1connect.ControllerServiceClient,
	registry *ProvisionerRegistry,
) (*Service, error)

func (*Service) GetArtefactDiffs added in v0.372.0

func (*Service) ReplaceDeploy added in v0.372.0

func (*Service) Status added in v0.372.0

func (*Service) UpdateDeploy added in v0.372.0

func (*Service) UploadArtefact added in v0.372.0

type Task added in v0.377.0

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

Task is a unit of work for a deployment

func (*Task) Progress added in v0.377.0

func (t *Task) Progress(ctx context.Context) error

func (*Task) Start added in v0.377.0

func (t *Task) Start(ctx context.Context) error

type TaskState added in v0.377.0

type TaskState string
const (
	TaskStatePending TaskState = ""
	TaskStateRunning TaskState = "running"
	TaskStateDone    TaskState = "done"
	TaskStateFailed  TaskState = "failed"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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