Documentation
¶
Index ¶
- Variables
- func NewSet(setSpecJSON string, db database.DB, logger *zap.Logger) (map[string]Provisioner, error)
- func Register(typ string, fn ProvisionerInitializer)
- type ClickhouseConfig
- type Provisioner
- type ProvisionerInitializer
- type ProvisionerSpec
- type Resource
- type ResourceOptions
- type ResourceType
- type RuntimeArgs
- type RuntimeConfig
Constants ¶
This section is empty.
Variables ¶
var Initializers = make(map[string]ProvisionerInitializer)
Initializers is a registry of provisioner initializers by type.
Functions ¶
func NewSet ¶ added in v0.43.0
NewSet initializes a set of provisioners from a JSON specification. The JSON specification should be a map of names to ProvisionerSpecs.
func Register ¶ added in v0.52.0
func Register(typ string, fn ProvisionerInitializer)
Register registers a new provisioner initializer.
Types ¶
type ClickhouseConfig ¶ added in v0.52.0
type ClickhouseConfig struct {
DSN string `mapstructure:"dsn"`
WriteDSN string `mapstructure:"write_dsn,omitempty"`
Cluster string `mapstructure:"cluster,omitempty"`
}
ClickhouseConfig describes the expected config for a provisioned Clickhouse resource.
func NewClickhouseConfig ¶ added in v0.52.0
func NewClickhouseConfig(cfg map[string]any) (*ClickhouseConfig, error)
func (*ClickhouseConfig) AsMap ¶ added in v0.52.0
func (c *ClickhouseConfig) AsMap() map[string]any
type Provisioner ¶
type Provisioner interface {
// Type returns the type of the provisioner.
Type() string
// Close is called when the provisioner is no longer needed.
Close() error
// Supports indicates if it can provision the resource type.
Supports(rt ResourceType) bool
// Provision provisions a new resource.
// It may be called multiple times for the same ID if:
// - the initial provision is interrupted, or
// - the resource args are updated
//
// This means Provision should be idempotent for the resource's ID (or otherwise do appropriate garbage collection in calls to Check).
Provision(ctx context.Context, r *Resource, opts *ResourceOptions) (*Resource, error)
// Deprovision deprovisions a resource.
Deprovision(ctx context.Context, r *Resource) error
// AwaitReady waits for a resource to be ready.
AwaitReady(ctx context.Context, r *Resource) error
// Check is called periodically to health check the provisioner.
// The provided context should have a generous timeout to allow the provisioner to perform maintenance tasks.
Check(ctx context.Context) error
// CheckResource is called periodically to health check a specific resource.
// The provided context should have a generous timeout to allow the provisioner to perform maintenance tasks for the resource.
// The resource's state map will be updated to match that of the returned value.
CheckResource(ctx context.Context, r *Resource, opts *ResourceOptions) (*Resource, error)
}
Provisioner is able to provision resources for one or more resource types.
type ProvisionerInitializer ¶ added in v0.52.0
type ProvisionerInitializer func(specJSON []byte, db database.DB, logger *zap.Logger) (Provisioner, error)
ProvisionerInitializer creates a new provisioner.
type ProvisionerSpec ¶ added in v0.43.0
type ProvisionerSpec struct {
Type string `json:"type"`
Spec json.RawMessage `json:"spec"`
}
ProvisionerSpec is a JSON-serializable specification for a provisioner.
type Resource ¶ added in v0.52.0
type Resource struct {
// ID uniquely identifies the provisioned resource.
ID string
// Type describes what type of service the resource is.
Type ResourceType
// State contains state about the provisioned resource for use by the provisioner.
// It should not be accessed outside of the provisioner.
State map[string]any
// Config contains access details for clients that use the resource.
Config map[string]any
}
Resource represents a provisioned resource.
type ResourceOptions ¶ added in v0.52.0
type ResourceOptions struct {
// Service-specific arguments for the provisioner. See resources.go for supported arguments.
Args map[string]any
// Annotations for the project the resource belongs to.
Annotations map[string]string
// RillVersion is the current version of Rill.
RillVersion string
}
ResourceOptions contains metadata about a resource.
type ResourceType ¶ added in v0.52.0
type ResourceType string
ResourceType enumerates the provisionable resource types.
const ( ResourceTypeRuntime ResourceType = "runtime" ResourceTypeClickHouse ResourceType = "clickhouse" )
func (ResourceType) Valid ¶ added in v0.53.0
func (r ResourceType) Valid() bool
type RuntimeArgs ¶ added in v0.52.0
type RuntimeArgs struct {
Slots int `mapstructure:"slots"`
Version string `mapstructure:"version"`
Environment string `mapstructure:"environment"`
}
RuntimeArgs describe the expected arguments for provisioning a runtime resource.
func NewRuntimeArgs ¶ added in v0.52.0
func NewRuntimeArgs(args map[string]any) (*RuntimeArgs, error)
func (*RuntimeArgs) AsMap ¶ added in v0.52.0
func (r *RuntimeArgs) AsMap() map[string]any
type RuntimeConfig ¶ added in v0.52.0
type RuntimeConfig struct {
Host string `mapstructure:"host"`
Audience string `mapstructure:"audience"`
CPU int `mapstructure:"cpu"`
MemoryGB int `mapstructure:"memory_gb"`
StorageBytes int64 `mapstructure:"storage_bytes"`
}
RuntimeConfig describes the expected config for a provisioned runtime resource.
func NewRuntimeConfig ¶ added in v0.52.0
func NewRuntimeConfig(cfg map[string]any) (*RuntimeConfig, error)
func (*RuntimeConfig) AsMap ¶ added in v0.52.0
func (r *RuntimeConfig) AsMap() map[string]any