services

package
v0.23.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MaxInstances = 10

MaxInstances is the most copies of one service this machine will run. A ceiling against a typo, not a recommendation: on one connection most providers pay for one. The web app uses the same number.

Variables

This section is empty.

Functions

func ValidateImage added in v0.22.0

func ValidateImage(image string) error

ValidateImage refuses a typed image that is not an image reference. "" is valid: it means the catalog image.

Types

type DeployOptions added in v0.23.0

type DeployOptions struct {
	// Image: see DeployImage.
	Image *string
	// Instances is how many copies of the service to run; see ScalingLimit.
	Instances *int
}

DeployOptions are the deploy form's choices beyond the credentials. A nil field means the box was left alone, and the deployment keeps what it already records.

type Manager

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

Manager owns the runtime provider registry and reconciles it against the store. providers is keyed by runtime kind; defaultKind is the kind used when a deployment or service does not name one — which is every service today, since Docker is the only registered runtime.

func NewManager

func NewManager(provider runtime.Provider, cat *catalog.Catalog, st *store.Store) *Manager

NewManager builds a Manager whose registry holds the given provider under defaultRuntimeKind, which also becomes the default kind. The signature is unchanged: callers still pass the single Docker provider, so the app stays single-runtime in behavior until a second provider is registered.

func (*Manager) Copies added in v0.23.0

func (m *Manager) Copies() map[string][]runtime.ContainerInfo

Copies returns copies 2..N of every service, by slug, as last seen.

func (*Manager) Deploy

func (m *Manager) Deploy(ctx context.Context, slug string, credentials map[string]string) (store.Deployment, error)

Deploy deploys slug from the image its deployment already uses: the catalog's, or the one the user chose on an earlier deploy. It is DeployImage with the image left out, which is what every caller that never shows an Image box should mean.

func (*Manager) DeployImage added in v0.22.0

func (m *Manager) DeployImage(ctx context.Context, slug string, credentials map[string]string, image *string) (store.Deployment, error)

DeployImage deploys slug, running image instead of the catalog's when one is given. nil keeps the image the deployment already records, "" goes back to the catalog, and anything else must pass ValidateImage before the runtime is touched. The choice is recorded with the deployment, so every later redeploy keeps it until cleared.

Only the image changes. Capabilities, devices, ports, the entrypoint and the stop timeout still come from the catalog entry, so a different image gains nothing the service does not already have.

func (*Manager) DeployWith added in v0.23.0

func (m *Manager) DeployWith(ctx context.Context, slug string, credentials map[string]string, opts DeployOptions) (store.Deployment, error)

DeployWith deploys slug with the given options. The first copy is deployed exactly as a single-copy service always was; copies 2..N follow it, and copies above N that are still running are removed, highest first.

func (*Manager) HasNativeRuntime added in v0.10.0

func (m *Manager) HasNativeRuntime() bool

HasNativeRuntime reports whether a provider is registered under the native runtime kind. Native execution has no external dependency (no daemon or socket to reach), so a registered native provider is by construction available — the app surfaces this alongside Docker's Status so onboarding can proceed on either signal. It reflects registration only; it never probes a running process.

func (*Manager) List added in v0.10.0

func (m *Manager) List(ctx context.Context) ([]runtime.ContainerInfo, error)

List returns every managed unit across all registered providers as a single flat slice — the monitoring/health view used by the app's health sampler. An error is returned only when no provider listed successfully; a partial failure yields the healthy providers' units (the failing provider's error is non-fatal). With just Docker registered this returns Docker's list unchanged, or Docker's error.

func (*Manager) Logs

func (m *Manager) Logs(ctx context.Context, slug string, lines int) (string, error)

func (*Manager) LogsCopy added in v0.23.0

func (m *Manager) LogsCopy(ctx context.Context, slug string, n, lines int) (string, error)

func (*Manager) PlanRemoval added in v0.17.8

func (m *Manager) PlanRemoval(ctx context.Context, slug string) (runtime.RemovalPlan, error)

PlanRemoval reports what removing a service would delete, so the confirmation the user is shown can name the data instead of saying "and its volumes".

func (*Manager) Refresh

func (m *Manager) Refresh(ctx context.Context) ([]store.Deployment, error)

func (*Manager) Register added in v0.10.0

func (m *Manager) Register(kind string, provider runtime.Provider)

Register adds a provider under the given runtime kind. It is the registration point the app uses to plug in additional runtimes (e.g. the native process runtime) after construction. Call it during Startup before the manager is shared with background reconciliation goroutines; it is not synchronized against a running Refresh.

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, slug string, deleteData, allowCritical bool) error

Remove removes the service. deleteData decides whether the data it stored goes with it; allowCritical is the separate yes needed for the volumes whose loss cannot be undone. Both default to false, so the ordinary "remove this service" leaves every node identity and keystore on disk for a later redeploy to pick up.

func (*Manager) RequiredCredentialsMet added in v0.11.0

func (m *Manager) RequiredCredentialsMet(slug string, credentials map[string]string) bool

RequiredCredentialsMet reports whether every required field for the service is present in the given credentials. Unlike ValidateCredentials it does not reject a manually tracked service, so the settings "Configured" badge can reflect whether the stored blob actually satisfies the current schema — not merely that it is non-empty, which an orphaned pre-migration blob (wrong keys) would also be.

func (*Manager) Restart

func (m *Manager) Restart(ctx context.Context, slug string) error

func (*Manager) ScalingLimit added in v0.23.0

func (m *Manager) ScalingLimit(svc catalog.Service) ScalingLimit

ScalingLimit decides the Instances box for svc. One copy where the provider allows one device per IP (a second copy behind the same address earns nothing), where the service has host volumes or published ports (copies would share the directories and fight over the ports), and where it runs as a native program here, which this app starts once. Otherwise MaxInstances. The reasons are the web app's wording.

func (*Manager) ScalingLimits added in v0.23.0

func (m *Manager) ScalingLimits(services []catalog.Service) map[string]ScalingLimit

ScalingLimits is ScalingLimit for every service in the catalog, by slug, for the deploy form.

func (*Manager) Start added in v0.6.0

func (m *Manager) Start(ctx context.Context, slug string) error

func (*Manager) StartCopy added in v0.23.0

func (m *Manager) StartCopy(ctx context.Context, slug string, n int) error

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context, slug string) error

func (*Manager) StopCopy added in v0.23.0

func (m *Manager) StopCopy(ctx context.Context, slug string, n int) error

func (*Manager) ValidateCredentials added in v0.11.0

func (m *Manager) ValidateCredentials(slug string, credentials map[string]string) error

ValidateCredentials reports whether the given credentials would let the service deploy — mirroring Deploy's pre-checks (known, deployable, required fields present) — so a caller can validate BEFORE persisting anything.

type ScalingLimit added in v0.23.0

type ScalingLimit struct {
	Max    int    `json:"max"`
	Reason string `json:"reason"`
}

ScalingLimit is how many copies of a service this machine may run, and why not more. Reason is "" when more than one is allowed.

Jump to

Keyboard shortcuts

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