Documentation ¶
Index ¶
- func Start(ctx context.Context, config Config, registry *ProvisionerRegistry, ...) error
- type CommonProvisionerConfig
- type Config
- type Deployment
- type DeploymentState
- type InMemProvisioner
- func (d *InMemProvisioner) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
- func (d *InMemProvisioner) Plan(context.Context, *connect.Request[provisioner.PlanRequest]) (*connect.Response[provisioner.PlanResponse], error)
- func (d *InMemProvisioner) Provision(ctx context.Context, req *connect.Request[provisioner.ProvisionRequest]) (*connect.Response[provisioner.ProvisionResponse], error)
- func (d *InMemProvisioner) Status(ctx context.Context, req *connect.Request[provisioner.StatusRequest]) (*connect.Response[provisioner.StatusResponse], error)
- type InMemResourceProvisionerFn
- type NoopProvisioner
- func (d *NoopProvisioner) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
- func (d *NoopProvisioner) Plan(context.Context, *connect.Request[provisioner.PlanRequest]) (*connect.Response[provisioner.PlanResponse], error)
- func (d *NoopProvisioner) Provision(context.Context, *connect.Request[provisioner.ProvisionRequest]) (*connect.Response[provisioner.ProvisionResponse], error)
- func (d *NoopProvisioner) Status(context.Context, *connect.Request[provisioner.StatusRequest]) (*connect.Response[provisioner.StatusResponse], error)
- type ProvisionerBinding
- type ProvisionerRegistry
- type ResourceEdge
- type ResourceGraph
- func (g *ResourceGraph) AddEdge(from, to *provisioner.Resource) *ResourceEdge
- func (g *ResourceGraph) AddNode(n *provisioner.Resource) *provisioner.Resource
- func (g *ResourceGraph) ByIDs(ids map[string]bool) []*provisioner.Resource
- func (g *ResourceGraph) Dependencies(id string) []*provisioner.Resource
- func (g *ResourceGraph) In(id string) []*ResourceEdge
- func (g *ResourceGraph) Node(id string) *provisioner.Resource
- func (g *ResourceGraph) Out(id string) []*ResourceEdge
- func (g *ResourceGraph) Resources() []*provisioner.Resource
- func (g *ResourceGraph) Roots() []*provisioner.Resource
- func (g *ResourceGraph) Update(resources []*provisioner.Resource)
- func (g *ResourceGraph) WithDirectDependencies(roots []*provisioner.Resource) *ResourceGraph
- type ResourceType
- type Service
- func (s *Service) CreateDeployment(ctx context.Context, req *connect.Request[ftlv1.CreateDeploymentRequest]) (*connect.Response[ftlv1.CreateDeploymentResponse], error)
- func (s *Service) GetArtefactDiffs(ctx context.Context, req *connect.Request[ftlv1.GetArtefactDiffsRequest]) (*connect.Response[ftlv1.GetArtefactDiffsResponse], error)
- func (s *Service) GetSchema(ctx context.Context, req *connect.Request[ftlv1.GetSchemaRequest]) (*connect.Response[ftlv1.GetSchemaResponse], error)
- func (s *Service) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
- func (s *Service) PullSchema(ctx context.Context, req *connect.Request[ftlv1.PullSchemaRequest], ...) error
- func (s *Service) ReplaceDeploy(ctx context.Context, req *connect.Request[ftlv1.ReplaceDeployRequest]) (*connect.Response[ftlv1.ReplaceDeployResponse], error)
- func (s *Service) Status(ctx context.Context, req *connect.Request[ftlv1.StatusRequest]) (*connect.Response[ftlv1.StatusResponse], error)
- func (s *Service) UpdateDeploy(ctx context.Context, req *connect.Request[ftlv1.UpdateDeployRequest]) (*connect.Response[ftlv1.UpdateDeployResponse], error)
- func (s *Service) UploadArtefact(ctx context.Context, req *connect.Request[ftlv1.UploadArtefactRequest]) (*connect.Response[ftlv1.UploadArtefactResponse], error)
- type Task
- type TaskState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start( ctx context.Context, config Config, registry *ProvisionerRegistry, controllerClient ftlv1connect.ControllerServiceClient, schemaClient ftlv1connect.SchemaServiceClient, ) 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_PROVISIONER_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 { Module string Tasks []*Task // Graph is the current state of the resources affected by the deployment Graph *ResourceGraph }
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 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) *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[ResourceType]InMemResourceProvisionerFn) *InMemProvisioner
func (*InMemProvisioner) Ping ¶ added in v0.377.0
func (d *InMemProvisioner) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
func (*InMemProvisioner) Plan ¶ added in v0.377.0
func (d *InMemProvisioner) Plan(context.Context, *connect.Request[provisioner.PlanRequest]) (*connect.Response[provisioner.PlanResponse], error)
func (*InMemProvisioner) Provision ¶ added in v0.377.0
func (d *InMemProvisioner) Provision(ctx context.Context, req *connect.Request[provisioner.ProvisionRequest]) (*connect.Response[provisioner.ProvisionResponse], error)
func (*InMemProvisioner) Status ¶ added in v0.377.0
func (d *InMemProvisioner) Status(ctx context.Context, req *connect.Request[provisioner.StatusRequest]) (*connect.Response[provisioner.StatusResponse], error)
type InMemResourceProvisionerFn ¶ added in v0.377.0
type InMemResourceProvisionerFn func(context.Context, *provisioner.ResourceContext, string, string) (*provisioner.Resource, error)
InMemResourceProvisionerFn is a function that provisions a resource
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 (d *NoopProvisioner) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
func (*NoopProvisioner) Plan ¶ added in v0.377.0
func (d *NoopProvisioner) Plan(context.Context, *connect.Request[provisioner.PlanRequest]) (*connect.Response[provisioner.PlanResponse], error)
func (*NoopProvisioner) Provision ¶ added in v0.377.0
func (d *NoopProvisioner) Provision(context.Context, *connect.Request[provisioner.ProvisionRequest]) (*connect.Response[provisioner.ProvisionResponse], error)
func (*NoopProvisioner) Status ¶ added in v0.377.0
func (d *NoopProvisioner) Status(context.Context, *connect.Request[provisioner.StatusRequest]) (*connect.Response[provisioner.StatusResponse], error)
type ProvisionerBinding ¶ added in v0.377.0
type ProvisionerBinding struct { Provisioner provisionerconnect.ProvisionerPluginServiceClient ID string Types []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 { Default *ProvisionerBinding Provisioners []*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) (*ProvisionerRegistry, error)
func (*ProvisionerRegistry) CreateDeployment ¶ added in v0.377.0
func (reg *ProvisionerRegistry) CreateDeployment(ctx context.Context, module string, desiredResources, existingResources *ResourceGraph) *Deployment
CreateDeployment to take the system to the desired state
func (*ProvisionerRegistry) Register ¶ added in v0.377.0
func (reg *ProvisionerRegistry) Register(id string, handler provisionerconnect.ProvisionerPluginServiceClient, types ...ResourceType) *ProvisionerBinding
Register to the registry, to be executed after all the previously added handlers
type ResourceEdge ¶ added in v0.377.0
type ResourceEdge struct {
// contains filtered or unexported fields
}
type ResourceGraph ¶ added in v0.377.0
type ResourceGraph struct {
// contains filtered or unexported fields
}
ResourceGraph is an in-memory graph of resources and their dependencies
func ExtractResources ¶ added in v0.377.0
func ExtractResources(msg *ftlv1.CreateDeploymentRequest) (*ResourceGraph, error)
ExtractResources from a module schema
func (*ResourceGraph) AddEdge ¶ added in v0.377.0
func (g *ResourceGraph) AddEdge(from, to *provisioner.Resource) *ResourceEdge
AddEdge between two nodes to the graph
func (*ResourceGraph) AddNode ¶ added in v0.377.0
func (g *ResourceGraph) AddNode(n *provisioner.Resource) *provisioner.Resource
AddNode to the graph
func (*ResourceGraph) ByIDs ¶ added in v0.390.0
func (g *ResourceGraph) ByIDs(ids map[string]bool) []*provisioner.Resource
ByIDs returns a slice of the resources with the given ids
func (*ResourceGraph) Dependencies ¶ added in v0.377.0
func (g *ResourceGraph) Dependencies(id string) []*provisioner.Resource
Dependencies returns all downstream dependencies of a node
func (*ResourceGraph) In ¶ added in v0.377.0
func (g *ResourceGraph) In(id string) []*ResourceEdge
In edges of a node
func (*ResourceGraph) Node ¶ added in v0.390.0
func (g *ResourceGraph) Node(id string) *provisioner.Resource
Node returns a node by id
func (*ResourceGraph) Out ¶ added in v0.377.0
func (g *ResourceGraph) Out(id string) []*ResourceEdge
Out edges of a node
func (*ResourceGraph) Resources ¶ added in v0.377.0
func (g *ResourceGraph) Resources() []*provisioner.Resource
Resources returns all nodes in the graph
func (*ResourceGraph) Roots ¶ added in v0.377.0
func (g *ResourceGraph) Roots() []*provisioner.Resource
Roots returns all nodes that have no incoming edges
func (*ResourceGraph) Update ¶ added in v0.390.0
func (g *ResourceGraph) Update(resources []*provisioner.Resource)
Update the state of existing resources
func (*ResourceGraph) WithDirectDependencies ¶ added in v0.377.0
func (g *ResourceGraph) WithDirectDependencies(roots []*provisioner.Resource) *ResourceGraph
WithDirectDependencies returns a subgraph of given nodes with their direct dependencies
type ResourceType ¶ added in v0.377.0
type ResourceType string
ResourceType is a type of resource used to configure provisioners
const ( ResourceTypeUnknown ResourceType = "unknown" ResourceTypePostgres ResourceType = "postgres" ResourceTypeMysql ResourceType = "mysql" ResourceTypeModule ResourceType = "module" )
func TypeOf ¶ added in v0.377.0
func TypeOf(r *provisioner.Resource) ResourceType
TypeOf returns the resource type of the given resource
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, config Config, controllerClient ftlv1connect.ControllerServiceClient, schemaClient ftlv1connect.SchemaServiceClient, registry *ProvisionerRegistry, ) (*Service, error)
func (*Service) CreateDeployment ¶
func (*Service) GetArtefactDiffs ¶ added in v0.372.0
func (*Service) PullSchema ¶ added in v0.372.0
func (s *Service) PullSchema(ctx context.Context, req *connect.Request[ftlv1.PullSchemaRequest], to *connect.ServerStream[ftlv1.PullSchemaResponse]) error