Documentation
¶
Overview ¶
Package sqlite provides an embedded SQLite database as an addon.
Unlike every other addon, this one runs no server. SQLite is an in-process library, so there is nothing to connect to: the addon arranges for a database to be mounted into the app's own container and hands back its path. That is what addon.InApp means, and why this package has no sandbox pool, no service, and no provisioning saga.
The database itself is a sqlite-provider disk (see controllers/sandbox/volume.go), created in WAL mode and replicated to the coordinator by components/sqlitedisk. This package only decides that the app should have one and where it goes.
Index ¶
- Constants
- func Definition() addon.AddonDefinition
- type Provider
- func (p *Provider) AdjustEnvVars(ctx context.Context, result *addon.ProvisionResult, ...) ([]addon.Variable, error)
- func (p *Provider) Deprovision(ctx context.Context, assoc addon.AddonAssociation) error
- func (p *Provider) LocalityMode() addon.LocalityMode
- func (p *Provider) Provision(ctx context.Context, assoc addon.AddonAssociation, app addon.App, ...) (*addon.ProvisionResult, error)
Constants ¶
const ( // AddonName is how the addon is declared in app.toml. AddonName = "miren-sqlite" // VariantStandard is the only variant. SQLite has no sizing to choose: // the database grows into the node's free space. VariantStandard = "standard" // DiskName names the disk contributed to each service. It identifies the // attachment, not the database: backup identity comes from the volume's // sqlite id, which this addon leaves unset so it takes the default. DiskName = "sqlite" // MountPath is where the database directory appears in the container. MountPath = "/data" // DbFile is the database's filename inside MountPath. DbFile = "data.db" )
const DatabasePath = MountPath + "/" + DbFile
DatabasePath is the full path the app opens.
Variables ¶
This section is empty.
Functions ¶
func Definition ¶
func Definition() addon.AddonDefinition
Definition describes the addon for the catalog and the CLI.
BaseImage and DefaultVersion are deliberately empty: an InApp addon has no container, and the registry skips image resolution and validation when there is no base image to resolve.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the SQLite addon.
It does not embed dbsaga.BaseProvider the way the server-backed addons do: that base hardcodes OnCluster locality and exists to share sandbox-pool saga steps, none of which apply here.
func NewProvider ¶
func NewProvider(fw *addon.ProviderFramework) *Provider
NewProvider returns a Provider. It takes the framework for signature parity with the other providers, but has no use for it: there are no entities to create, since the database follows the app's own sandbox.
func (*Provider) AdjustEnvVars ¶
func (p *Provider) AdjustEnvVars(ctx context.Context, result *addon.ProvisionResult, assoc addon.AddonAssociation, collisions []string) ([]addon.Variable, error)
AdjustEnvVars leaves the variables alone on collision, matching every other provider. A user who has already set DATABASE_URL keeps their value, because the controller never overwrites a manually set variable.
func (*Provider) Deprovision ¶
Deprovision has nothing of its own to tear down. The controller removes the disk from the app's config, which stops replication and detaches the database when the app next reconciles.
The database file itself is deliberately left on the node, matching how a miren disk survives app deletion: the data is the user's, and an addon detaching is not a request to destroy it.
func (*Provider) LocalityMode ¶
func (p *Provider) LocalityMode() addon.LocalityMode
func (*Provider) Provision ¶
func (p *Provider) Provision(ctx context.Context, assoc addon.AddonAssociation, app addon.App, variant addon.Variant) (*addon.ProvisionResult, error)
Provision contributes the database to the app. There is nothing to create here: the disk is materialized when the app's sandbox next starts, and the database itself is created and replicated by the sqlite disk provider.