Documentation
¶
Overview ¶
Package databases provisions and manages database containers: per-engine image/env/volume defaults plus dump & restore commands.
Index ¶
- Constants
- Variables
- func CanFork(engine string) bool
- func CanProvision(engine string) bool
- func DefaultOutput(engine string) string
- func Eligible(ctx context.Context, store repo.Store, instance, consumer *repo.Tile) bool
- func EligibleInstances(ctx context.Context, store repo.Store, consumer *repo.Tile) ([]repo.Tile, error)
- func HasSliceStats(engine string) bool
- func InfraPath(scopeKind, orgSlug, stackSlug, envSlug, tileSlug string) string
- func NewDB(d *repo.Tile) error
- func PublishConnection(ctx context.Context, store repo.Store, d *repo.Tile)
- func Ref(instance *repo.Tile, p *repo.Provision, output string) string
- func ResolveInfraPath(ctx context.Context, store repo.Store, path string) (*repo.Tile, error)
- func ResourceSlug(instance *repo.Tile, p *repo.Provision) string
- func ScopeLabel(kind string) string
- func ServesEnv(ctx context.Context, store repo.Store, instance *repo.Tile, ...) bool
- func SharedNet(instance *repo.Tile) string
- func SliceName(engine, name string) string
- func SpeaksHTTP(engine string) bool
- func URL(d *repo.Tile) string
- func VolumeName(d *repo.Tile) string
- type ConnVar
- type DataVolume
- type Engine
- type EngineOption
- type InfraTarget
- type PGCreds
- type ResolveScope
- type S3Object
- type Service
- func (s *Service) AttachExisting(ctx context.Context, instance *repo.Tile, src *repo.Provision, ...) (*repo.Provision, error)
- func (s *Service) AutoInjectVars(ctx context.Context, instance *repo.Tile, p *repo.Provision) map[string]string
- func (s *Service) CloneSlice(ctx context.Context, instance *repo.Tile, envID, slug, name string, ...) (*repo.Provision, error)
- func (s *Service) ContainerID(ctx context.Context, d *repo.Tile) (string, error)
- func (s *Service) DataVolume(ctx context.Context, d *repo.Tile) DataVolume
- func (s *Service) Deploy(ctx context.Context, d *repo.Tile) error
- func (s *Service) Detach(ctx context.Context, p *repo.Provision) error
- func (s *Service) DropDB(ctx context.Context, instance *repo.Tile, dbName string) error
- func (s *Service) EnsureProvisions(ctx context.Context, consumer *repo.Tile, w io.Writer)
- func (s *Service) ForkSlice(ctx context.Context, instance *repo.Tile, src *repo.Provision, ...) (*repo.Provision, error)
- func (s *Service) PGDeleteRow(ctx context.Context, instance *repo.Tile, cr PGCreds, table, ctid string) error
- func (s *Service) PGInsertRow(ctx context.Context, instance *repo.Tile, cr PGCreds, table string, ...) error
- func (s *Service) PGSelect(ctx context.Context, instance *repo.Tile, cr PGCreds, table string, ...) (cols []string, rows [][]string, total int64, err error)
- func (s *Service) PGTables(ctx context.Context, instance *repo.Tile, cr PGCreds) ([]string, error)
- func (s *Service) PGUpdateCell(ctx context.Context, instance *repo.Tile, cr PGCreds, ...) error
- func (s *Service) Provision(ctx context.Context, instance, consumer *repo.Tile, name string, public bool) (*repo.Provision, error)
- func (s *Service) ProvisionSlice(ctx context.Context, instance *repo.Tile, envID, slug, name string, ...) (*repo.Provision, error)
- func (s *Service) Ready(ctx context.Context, instance *repo.Tile) error
- func (s *Service) ReconcileOwnProvisions(ctx context.Context, instance *repo.Tile, w io.Writer)
- func (s *Service) Remove(ctx context.Context, d *repo.Tile) error
- func (s *Service) S3Delete(ctx context.Context, instance *repo.Tile, bucket, key string, dir bool) error
- func (s *Service) S3Get(ctx context.Context, instance *repo.Tile, bucket, key string) (io.ReadCloser, error)
- func (s *Service) S3List(ctx context.Context, instance *repo.Tile, bucket, dir string) ([]S3Object, error)
- func (s *Service) S3Put(ctx context.Context, instance *repo.Tile, bucket, key string, src io.Reader) error
- func (s *Service) ServiceName(ctx context.Context, d *repo.Tile) string
- func (s *Service) SetBucketPublic(ctx context.Context, instance *repo.Tile, p *repo.Provision, public bool) error
- func (s *Service) SliceStats(ctx context.Context, instance *repo.Tile, dbNames []string) (map[string]SliceStat, error)
- func (s *Service) Start(ctx context.Context, d *repo.Tile) error
- func (s *Service) Stop(ctx context.Context, d *repo.Tile) error
- func (s *Service) SyncResource(ctx context.Context, instance *repo.Tile, p *repo.Provision) error
- func (s *Service) WaitReady(ctx context.Context, instance *repo.Tile, timeout time.Duration) error
- type SharedDB
- type SliceStat
Constants ¶
const ( TargetInstance = "instance" TargetSlice = "slice" )
Target kinds.
const PGNull = "␀" // ␀
PGNull is the sentinel psql prints for NULL so csv parsing can tell it from an empty string. a real cell holding exactly this glyph reads as NULL; pick a longer marker if that ever bites.
Variables ¶
var Engines = map[string]Engine{ "postgres": { SliceName: sqlIdent, Label: "PostgreSQL", Order: 1, DefaultImage: "postgres:17", Port: 5432, DataPath: "/var/lib/postgresql/data", SecretSuffix: "_url", PrimaryOutput: "DATABASE_URL", SliceNoun: "logical db", UnitNoun: "database", Icon: "", SlicePath: "pgdbs", DataBrowser: true, Env: func(d *repo.Tile) []string { return []string{"POSTGRES_DB=" + d.DBName, "POSTGRES_USER=" + d.DBUser, "POSTGRES_PASSWORD=" + d.DBPassword} }, DumpCmd: func(d *repo.Tile) []string { return []string{"env", "PGPASSWORD=" + d.DBPassword, "pg_dump", "-U", d.DBUser, "-d", d.DBName} }, RestoreCmd: func(d *repo.Tile) []string { script := `PGPASSWORD="$0" psql -v ON_ERROR_STOP=1 -U "$1" -d "$2" ` + `-c 'DROP SCHEMA public CASCADE' -c 'CREATE SCHEMA public' >/dev/null && ` + `PGPASSWORD="$0" psql -v ON_ERROR_STOP=1 -U "$1" -d "$2" >/dev/null` return []string{"sh", "-c", script, d.DBPassword, d.DBUser, d.DBName} }, }, "s3": { Label: "S3 object storage", Order: 5, DefaultImage: "rustfs/rustfs:latest", Port: 9000, HTTP: true, DataPath: "/data", PrimaryOutput: "S3_ENDPOINT", AutoInjectAll: true, PublicSlices: true, SliceNoun: "bucket", UnitNoun: "bucket", Shape: "bucket", SlicePath: "buckets", FileBrowser: true, Env: func(d *repo.Tile) []string { return []string{"RUSTFS_ACCESS_KEY=" + d.DBUser, "RUSTFS_SECRET_KEY=" + d.DBPassword} }, Cmd: func(d *repo.Tile) []string { return []string{"--console-enable", "/data"} }, }, }
Functions ¶
func CanFork ¶
CanFork reports whether the engine can copy a slice's data, the way CanProvision reports whether it can cut one.
func CanProvision ¶
CanProvision reports whether the engine supports provisioning a per-consumer slice (a logical db for postgres, a bucket for s3), i.e. whether its registry entry carries a Provision hook.
func DefaultOutput ¶
DefaultOutput is the output a consumer wants when it names no specific one.
func Eligible ¶
Eligible reports whether consumer may provision from instance given the instance's sharing scope: env = same environment, stack = same stack, org = same organization.
func EligibleInstances ¶
func EligibleInstances(ctx context.Context, store repo.Store, consumer *repo.Tile) ([]repo.Tile, error)
EligibleInstances lists every provisionable shared db instance a consumer tile may use, across env/stack/org scope.
func HasSliceStats ¶
HasSliceStats reports whether this engine measures its slices at all.
func InfraPath ¶
InfraPath is the human-facing address of a shared instance. The segment count encodes the scope: org-scoped instances are addressed org:slug, stack-scoped org:stack:slug, env-scoped org:stack:env:slug.
func PublishConnection ¶
PublishConnection stores/refreshes a db tile's own connection details as variables on that tile, so a consumer can read them directly with ${{ tile.<slug>.DATABASE_URL }}, the case where a service just uses the database rather than being provisioned a slice of it.
They live as tile variables rather than a managed resource because a resource sharing the tile's slug would make every reference ambiguous.
func Ref ¶
Ref is the reference expression a consumer puts in a variable to read one of a slice's outputs.
func ResolveInfraPath ¶
ResolveInfraPath turns an InfraPath back into its instance tile. The walk depth follows the segment count; org/stack-scoped instances live in some env but are addressed at the higher scope, so those two cases scan for the tile.
func ResourceSlug ¶
ResourceSlug is the name a provisioned slice answers to in a reference: ${{ tile.<slug>.DATABASE_URL }}. A config-declared slice carries its config key on the row; otherwise the slug is derived, qualified by the instance because a bucket or db name is only unique per instance, while the slug must be unique per environment.
func ScopeLabel ¶
ScopeLabel is the human name for a tile's sharing scope.
func ServesEnv ¶
func ServesEnv(ctx context.Context, store repo.Store, instance *repo.Tile, env *repo.Environment) bool
ServesEnv reports whether an instance's sharing scope reaches into an environment, i.e. whether a slice cut for that env could ever be consumed from it.
Worth checking at provision time and not only at attach: a slice records the env it belongs to, and AttachExisting refuses across envs, so a slice cut into the wrong env is a database nothing can ever use.
func SharedNet ¶
SharedNet is the per-instance Docker network that consumers of a shared db join to reach it across environment/stack boundaries. Empty until the instance has claimed one; call ensureSharedNet first.
func SliceName ¶
SliceName is the name engine would give a slice asked for as name, before uniquifying. The one place a config name and a stored name meet.
func SpeaksHTTP ¶
SpeaksHTTP reports whether this engine can sit behind Traefik.
func URL ¶
URL is the primary connection detail for a DB tile, the first thing Conn publishes.
no caller since the drawer started listing Conn in full. Kept because "the one string that identifies this instance" is what a CLI `stackr db url` and the config-as-code exporter both want, and rederiving "first entry" at each of them is worse.
func VolumeName ¶
VolumeName is the named Docker volume holding this DB's data. Keeps the "stackr-" prefix, see repo.StorageVolume for why.
Types ¶
type DataVolume ¶
type DataVolume struct {
runtime.VolumeInfo
MountPath string
}
DataVolume describes the docker volume holding a DB's data: what the graph's tucked volume card opens. MountPath is where the engine sees it inside the container; the rest comes from docker.
type Engine ¶
type Engine struct {
DefaultImage string
Port int
DataPath string
// HTTP marks an engine that speaks HTTP on Port, so Traefik can put a
// domain in front of it. Wire-protocol engines (postgres, mysql, redis…)
// cannot be proxied by an HTTP router, a domain on one would resolve and
// then never work, which is worse than not offering it.
HTTP bool
// Env builds container env for first boot.
Env func(d *repo.Tile) []string
// Cmd overrides the container command (nil = image default).
Cmd func(d *repo.Tile) []string
// DumpCmd streams a logical dump to stdout inside the container.
//
// DumpCmd/RestoreCmd have had no caller since the backups
// feature was removed. Kept deliberately, the backup rethink and db
// forking both need exactly this table, and re-deriving the per-engine
// flags is the expensive part.
DumpCmd func(d *repo.Tile) []string
// RestoreCmd consumes a dump from stdin inside the container (nil = restore unsupported).
RestoreCmd func(d *repo.Tile) []string
// RootUser overrides the generated admin user ("" = the tile slug).
RootUser string
// SecretSuffix ends the provision's (vestigial) secret name.
SecretSuffix string
// PrimaryOutput is the output a consumer reads when it names none.
PrimaryOutput string
// AutoInjectAll marks engines whose slices need their whole output set
// wired into a consumer (endpoint + bucket + keys), not one url.
AutoInjectAll bool
// PublicSlices marks engines whose slices can be published read-only
// (s3 bucket policies); everything else rejects the request.
PublicSlices bool
// Conn are the connection details published on the instance tile itself,
// for a consumer that just uses the database rather than being cut a
// slice of it. The first entry is the primary one, what the drawer's
// Copy button copies. nil = this engine publishes nothing.
Conn func(d *repo.Tile) []ConnVar
// SliceName normalises a requested slice name into what the engine can
// actually create (SQL engines fold "-" to "_"). nil = the name is taken
// as-is. Every reader of a slice name goes through the SliceName func
// below so the config diff compares what the provisioner stored.
SliceName func(name string) string
// Provisioning hooks. A nil Provision means the engine cannot cut
// per-consumer slices; everything else is optional and degrades to
// "nothing to do" rather than to a special case somewhere else.
Provision func(s *Service, ctx context.Context, instance, consumer *repo.Tile, name string, public bool) (*repo.Provision, error)
Drop func(s *Service, ctx context.Context, instance *repo.Tile, p *repo.Provision) error
// Fork copies a live slice's data into dst, which ForkSlice has already
// provisioned empty on the same instance. nil = this engine can provision
// but not copy, which is a clean error rather than a silent empty fork.
Fork func(s *Service, ctx context.Context, instance *repo.Tile, src, dst *repo.Provision) error
Ensure func(s *Service, ctx context.Context, instance *repo.Tile, p *repo.Provision, w io.Writer)
Outputs func(s *Service, ctx context.Context, instance *repo.Tile, p *repo.Provision) []repo.ResourceOutput
Ready func(s *Service, ctx context.Context, instance *repo.Tile, containerID string) error
SliceStats func(s *Service, ctx context.Context, instance *repo.Tile, names []string) (map[string]SliceStat, error)
// Display. SliceNoun/UnitNoun name the engine's parts in the UI
// ("logical db"/"database" vs "bucket"/"bucket"); Icon is the sprite
// symbol for engines with a real logo ("" = draw the stroke glyph named
// by Shape, default a cylinder); SlicePath is the URL segment of the
// engine's own per-slice UI ("" = slices open the instance drawer).
SliceNoun string
UnitNoun string
Icon string
Shape string
SlicePath string
// Label is the engine's product name for pickers; Order sorts them there
// (lowest first) so the list has an opinion without a second list to keep.
Label string
Order int
// DataBrowser/FileBrowser mark the engine-owned content UIs, so the
// handlers and the drawer tabs ask the registry instead of the engine
// name.
DataBrowser bool
FileBrowser bool
}
Engine describes one supported database engine.
type EngineOption ¶
type EngineOption struct {
Name string // registry key, the value submitted
Label string // product name
}
EngineOption is one entry of the engine picker.
func EngineOptions ¶
func EngineOptions() []EngineOption
EngineOptions lists the engines a user can create, in Order. Registering an engine is what puts it in the picker, there is no second list.
type InfraTarget ¶
type InfraTarget struct {
Kind string
Instance *repo.Tile // always set, a slice's instance is its provider
Provision *repo.Provision // set only for TargetSlice
Path string // the fully-qualified form, for prompts and output
}
InfraTarget is what a path resolved to. Callers switch on Kind rather than on which pointer happens to be nil.
func ResolveTarget ¶
func ResolveTarget(ctx context.Context, store repo.Store, path string, scope ResolveScope) (*InfraTarget, error)
ResolveTarget turns an infra path into the instance or slice it names.
A relative reading is tried first (narrowest scope first) and then an absolute one. If both resolve to different things the path is ambiguous and this errors rather than picking, the same address would otherwise mean different things depending on which directory you ran it from.
type PGCreds ¶
type PGCreds struct {
User, Password, DB string
}
PGCreds is one resolved connection scope.
type ResolveScope ¶
type ResolveScope struct {
// AllowedOrgs limits the search to these org ids. A nil map means no
// limit, which is only correct for server-side callers acting on their own
// behalf, never for anything driven by a request. Use SystemScope to say
// so deliberately.
AllowedOrgs map[string]bool
// EnvID is the caller's linked environment. Set, it enables relative
// paths; empty, only absolute paths resolve.
EnvID string
}
ResolveScope bounds a resolution to what its caller may see and where it is standing.
func SystemScope ¶
func SystemScope() ResolveScope
SystemScope resolves without an access check, for internal callers such as the config applier. Named so that granting unrestricted access is greppable rather than an omitted argument.
type S3Object ¶
type S3Object struct {
Name string // last path segment
Dir bool // a common prefix ("folder")
Size int64
ModTime time.Time
}
S3Object is one entry of a bucket listing at a given prefix.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages database container lifecycle.
Every docker call goes through the cluster, which decides socket or agent. This package used to carry its own copy of that decision behind an optional WithNodes, and twelve of the thirteen places that built a Service never called it, so every exec ran against the manager whatever node the instance was on (docs/plans/35-cluster.md).
func (*Service) AttachExisting ¶
func (s *Service) AttachExisting(ctx context.Context, instance *repo.Tile, src *repo.Provision, consumer *repo.Tile) (*repo.Provision, error)
AttachExisting points a second consumer at an existing logical db (same creds), so cron jobs and services can share one database. Same env only, the url secret is env-scoped. No CREATE DATABASE; just a new consumer row + its own url secret. The consumer joins the shared net on its next deploy.
func (*Service) AutoInjectVars ¶
func (s *Service) AutoInjectVars(ctx context.Context, instance *repo.Tile, p *repo.Provision) map[string]string
AutoInjectVars maps every output a slice publishes to a reference at it, what a consumer needs wired when one connection url is not enough (s3: endpoint, bucket, keys). Derived from the outputs themselves so the two cannot drift.
func (*Service) CloneSlice ¶
func (s *Service) CloneSlice(ctx context.Context, instance *repo.Tile, envID, slug, name string, public bool) (*repo.Provision, error)
CloneSlice cuts a fresh slice for a cloned env under the same reference slug, a new database/bucket (name uniquified against the instance), never a second consumer of the base env's data.
func (*Service) ContainerID ¶
ContainerID returns the current container ID for the DB ("" if none). The service's task container carries the same label the plain container did, so exec, stats and the sql browser keep their call.
func (*Service) DataVolume ¶
DataVolume inspects a DB tile's data volume. A volume that docker doesn't know about yet (tile created, never deployed) still returns its name and mount path with an unknown size.
func (*Service) Deploy ¶
Deploy pulls the image and creates or updates the DB's swarm service.
A managed db is a pinned tile: one replica, stop-first, placed on the node that holds its volume. Two tasks on one data directory corrupt it, and a task scheduled onto a node with an empty disk is silent data loss, not an error (docs/plans/30-docker-swarm.md, the volume addendum).
Every network the instance needs is in the spec before the service exists. A service cannot join one afterwards without rolling every task, so the shared network a provisioned instance's consumers reach it on is claimed here, not connected after the fact.
func (*Service) Detach ¶
Detach unlinks the consumer but keeps the logical db (orphaned), revoking the binding so its references stop resolving.
func (*Service) DropDB ¶
DropDB destroys a provisioned slice (logical database, bucket) and removes every consumer's provision row with it. This is the whole-slice teardown from the instance panel; per-consumer removal is Detach on the consumer side.
func (*Service) EnsureProvisions ¶
EnsureProvisions reconciles a consumer's provisioned dependencies before it deploys. Each provisions row is desired state, so a db/role/bucket that was dropped out from under the consumer (and its connection secret) is recreated from the row. The secret is always republished (it needs no instance); the backing store is best-effort, so a down instance never fails the consumer's deploy (the app retries its own connection).
runs on every deploy, one psql/S3 round-trip per provisioned dep. Deploys are not hot-path; gate it on "secret missing" if that ever bites.
func (*Service) ForkSlice ¶
func (s *Service) ForkSlice(ctx context.Context, instance *repo.Tile, src *repo.Provision, slug, name string) (*repo.Provision, error)
ForkSlice provisions a fresh slice alongside src on the same instance and copies src's data into it.
name is the new database/bucket name ("" derives it from src, and Provision uniquifies it against the instance); slug is the fork's reference name ("" derives it from src's, uniquified against the env).
The fork lands in the source's environment with no consumer, structurally the same row a config-declared slice has, so it appears in the instance drawer and can be attached to a consumer later through the existing flow. It is never public: a fork exists to be experimented on, and inheriting a source bucket's world-readability would publish that experiment.
func (*Service) PGDeleteRow ¶
func (s *Service) PGDeleteRow(ctx context.Context, instance *repo.Tile, cr PGCreds, table, ctid string) error
PGDeleteRow removes the row at ctid.
func (*Service) PGInsertRow ¶
func (s *Service) PGInsertRow(ctx context.Context, instance *repo.Tile, cr PGCreds, table string, cols, values []string) error
PGInsertRow inserts one row from the filled columns; empty inputs are left to their column defaults. No filled columns inserts an all-defaults row.
func (*Service) PGSelect ¶
func (s *Service) PGSelect(ctx context.Context, instance *repo.Tile, cr PGCreds, table string, limit, offset int) (cols []string, rows [][]string, total int64, err error)
PGSelect returns one page of a table: column names (without the leading ctid), rows (each row[0] is the ctid), and the total row count.
func (*Service) PGTables ¶
PGTables lists the base tables the connection can see, as "schema.table".
func (*Service) PGUpdateCell ¶
func (s *Service) PGUpdateCell(ctx context.Context, instance *repo.Tile, cr PGCreds, table, ctid, col, value string, null bool) error
PGUpdateCell sets one column of the row at ctid (null=true writes NULL).
func (*Service) Provision ¶
func (s *Service) Provision(ctx context.Context, instance, consumer *repo.Tile, name string, public bool) (*repo.Provision, error)
Provision cuts a per-consumer slice out of the shared instance, a logical database for postgres, a bucket for s3, records it, and publishes its connection details as resource outputs. name is the slice name; "" derives it from the consumer slug. It is uniquified against the instance's existing slices. public asks for unauthenticated read access, which only engines with PublicSlices support.
func (*Service) ProvisionSlice ¶
func (s *Service) ProvisionSlice(ctx context.Context, instance *repo.Tile, envID, slug, name string, public bool) (*repo.Provision, error)
ProvisionSlice cuts (or adopts) a config-declared slice: slug is its reference name (the config key), name the db/bucket name, envID where it lives. No consumer on the row, consumers are whichever tiles reference it, bound at apply time.
An existing slice on the instance with the same name and env is adopted (re-stamped with the slug, revived if orphaned) rather than uniquified into a silent second copy: the file names the slice it means.
func (*Service) ReconcileOwnProvisions ¶
ReconcileOwnProvisions recreates every slice provisioned on this instance, the instance-side self-heal, run after the instance starts or redeploys. It closes the gap EnsureProvisions leaves open: a consumer deployed while the instance was down gets its role/db/bucket the moment the instance returns, without a consumer redeploy.
func (*Service) Remove ¶
Remove removes the DB service (data volume is left behind on purpose). Its shared network goes back to the pool, callers gate delete on there being no remaining provisions, so nothing else is attached.
Service first, network second. Releasing first put the name back in the pool while the instance's own service was still attached to it, so the next environment to claim that name inherited a database it could reach by DNS.
func (*Service) S3Delete ¶
func (s *Service) S3Delete(ctx context.Context, instance *repo.Tile, bucket, key string, dir bool) error
S3Delete removes one object, or a whole "folder" (key ending in /), object storage has no directories, so a folder delete is a prefix sweep.
func (*Service) S3Get ¶
func (s *Service) S3Get(ctx context.Context, instance *repo.Tile, bucket, key string) (io.ReadCloser, error)
S3Get streams one object out of the bucket.
func (*Service) S3List ¶
func (s *Service) S3List(ctx context.Context, instance *repo.Tile, bucket, dir string) ([]S3Object, error)
S3List lists the objects and pseudo-folders directly under dir in the bucket, folders first.
func (*Service) S3Put ¶
func (s *Service) S3Put(ctx context.Context, instance *repo.Tile, bucket, key string, src io.Reader) error
S3Put writes src as an object. src should be seekable (an uploaded form file is) so the SDK can size and sign the payload.
func (*Service) ServiceName ¶
ServiceName is the swarm service the instance runs as ("" when its scope cannot be resolved).
func (*Service) SetBucketPublic ¶
func (s *Service) SetBucketPublic(ctx context.Context, instance *repo.Tile, p *repo.Provision, public bool) error
SetBucketPublic flips an existing bucket's public-read policy and records it on the provision, so exposure is a setting rather than a decision frozen at creation. Provisioning could already do this; nothing could undo it.
The mirrored managed_resource and its outputs are re-synced, because S3_PUBLIC_URL only exists while the bucket is public.
func (*Service) SliceStats ¶
func (s *Service) SliceStats(ctx context.Context, instance *repo.Tile, dbNames []string) (map[string]SliceStat, error)
SliceStats reads per-slice counters from an instance. Engines with no counters to read report none.
func (*Service) Start ¶
Start scales a stopped instance back to one replica, or deploys it when it has no service yet.
func (*Service) Stop ¶
Stop scales the service to zero, keeping the service and its data volume. Stopping the task container instead would just get a replacement.
func (*Service) SyncResource ¶
SyncResource creates or refreshes the resource behind a provision and binds its consumer. Idempotent per (instance, slice): AttachExisting adds a second provision row for the same slice, which must contribute a binding only, a second resource row would collide on UNIQUE(environment_id, slug).
func (*Service) WaitReady ¶
WaitReady polls Ready until timeout.
It used to check for a container once up front and give up if there was none, on the reasoning that waiting cannot conjure one. That was wrong in the case the wait exists for: one apply creates a shared instance and the slices cut from it, and for the first few seconds the instance has a swarm service but no running task yet. The pre-check fired instead of the wait, so every slice failed with "instance sharedpg is not running" and only a second apply ever worked.
A container that genuinely never arrives still fails, just at the deadline with the same message.