Documentation
¶
Index ¶
- Constants
- type ContainerInfo
- type DeploySpec
- type DockerProvider
- func (p *DockerProvider) Deploy(ctx context.Context, spec DeploySpec, progress func(string)) (ContainerInfo, error)
- func (p *DockerProvider) List(ctx context.Context) ([]ContainerInfo, error)
- func (p *DockerProvider) Logs(ctx context.Context, slug string, lines int) (string, error)
- func (p *DockerProvider) Remove(ctx context.Context, slug string) error
- func (p *DockerProvider) Restart(ctx context.Context, slug string) error
- func (p *DockerProvider) Start(ctx context.Context, slug string) error
- func (p *DockerProvider) Status(ctx context.Context) Status
- func (p *DockerProvider) Stop(ctx context.Context, slug string) error
- type InstallGuide
- type ManagedRuntimePlan
- type NativeProcessProvider
- func (p *NativeProcessProvider) Deploy(ctx context.Context, spec DeploySpec, progress func(string)) (ContainerInfo, error)
- func (p *NativeProcessProvider) List(ctx context.Context) ([]ContainerInfo, error)
- func (p *NativeProcessProvider) Logs(ctx context.Context, slug string, lines int) (string, error)
- func (p *NativeProcessProvider) Remove(ctx context.Context, slug string) error
- func (p *NativeProcessProvider) Restart(ctx context.Context, slug string) error
- func (p *NativeProcessProvider) SetEventRecorder(fn func(slug, event, detail string))
- func (p *NativeProcessProvider) Start(ctx context.Context, slug string) error
- func (p *NativeProcessProvider) Status(ctx context.Context) Status
- func (p *NativeProcessProvider) Stop(ctx context.Context, slug string) error
- type Provider
- type Status
Constants ¶
const ( LabelManaged = "cashpilot.managed" LabelService = "cashpilot.service" LabelVersion = "cashpilot.version" LabelRuntime = "cashpilot.runtime" )
const NativeRuntimeKind = "native"
NativeRuntimeKind is the runtime-kind key the NativeProcessProvider registers under in the services manager. A service that declares a native binary for the host is routed onto this runtime; image-only services stay on Docker.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerInfo ¶
type DeploySpec ¶
type DockerProvider ¶
type DockerProvider struct{}
func NewDockerProvider ¶
func NewDockerProvider() *DockerProvider
func (*DockerProvider) Deploy ¶
func (p *DockerProvider) Deploy(ctx context.Context, spec DeploySpec, progress func(string)) (ContainerInfo, error)
func (*DockerProvider) List ¶
func (p *DockerProvider) List(ctx context.Context) ([]ContainerInfo, error)
func (*DockerProvider) Remove ¶
func (p *DockerProvider) Remove(ctx context.Context, slug string) error
func (*DockerProvider) Restart ¶
func (p *DockerProvider) Restart(ctx context.Context, slug string) error
type InstallGuide ¶
type InstallGuide struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Platforms []string `json:"platforms"`
URL string `json:"url"`
Commands []string `json:"commands"`
Notes []string `json:"notes"`
}
func InstallGuides ¶
func InstallGuides() []InstallGuide
func (InstallGuide) Supports ¶ added in v0.4.4
func (g InstallGuide) Supports(osName string) bool
type ManagedRuntimePlan ¶
type ManagedRuntimePlan struct {
Summary string `json:"summary"`
Phases []string `json:"phases"`
Risks []string `json:"risks"`
Providers []string `json:"providers"`
}
func ManagedRuntimeRoadmap ¶
func ManagedRuntimeRoadmap() ManagedRuntimePlan
type NativeProcessProvider ¶ added in v0.10.0
type NativeProcessProvider struct {
// contains filtered or unexported fields
}
NativeProcessProvider runs catalog services as supervised native child processes, with no container runtime. It downloads each service's SHA-256-pinned binary over HTTPS, verifies it (fail-closed on mismatch or a missing/invalid checksum), extracts it under <appDir>/native/<slug>/, and launches it with an argv built from the service's native.command via the same shell-safe tokenizeCommand/substitute path Docker uses. stdout+stderr are captured to a bounded rotating log; a supervisor goroutine restarts a crashed process with bounded backoff (the native equivalent of Docker's restart policy). A JSON registry at <appDir>/native/state.json records each managed process (pid, binary, args, source url/sha, startedAt, desired state) so List/Start/Stop/Remove survive an app restart.
It implements runtime.Provider. ContainerInfo fields are repurposed for a process: ContainerID is the pid, Image is the source binary URL, Status is running/stopped, and CPU/memory come from gopsutil best-effort.
func NewNativeProcessProvider ¶ added in v0.10.0
func NewNativeProcessProvider(appDir string) *NativeProcessProvider
NewNativeProcessProvider builds a provider rooted at <appDir>/native with production defaults.
func (*NativeProcessProvider) Deploy ¶ added in v0.10.0
func (p *NativeProcessProvider) Deploy(ctx context.Context, spec DeploySpec, progress func(string)) (ContainerInfo, error)
Deploy downloads+verifies+extracts the service's native binary for this host and launches it as a supervised process. It mirrors DockerProvider.Deploy's shape (progress callbacks, redeploy replaces a prior instance) but targets a native process instead of a container.
func (*NativeProcessProvider) List ¶ added in v0.10.0
func (p *NativeProcessProvider) List(ctx context.Context) ([]ContainerInfo, error)
List reports every registry entry as a ContainerInfo, checking each recorded pid's liveness (and best-effort CPU/memory) via gopsutil. A process that isn't reachable reports zeros and status "stopped"; it never panics on a dead/reused pid.
Alive entries are sampled CONCURRENTLY (mirroring DockerProvider.statsForContainers): each goroutine owns its own out[i] slot, so no locking/shared map is needed, and a buffered semaphore bounds how many statFn calls run at once. A serial loop would make this O(N * cpuStatInterval); with the fan-out the added latency stays ~one interval regardless of N. Stopped entries are written synchronously (no sampling needed), and the result stays sorted by slug just like the previous serial loop.
func (*NativeProcessProvider) Logs ¶ added in v0.10.0
Logs returns the tail of the service's captured stdout+stderr, reading the rotated previous generation then the current one, bounded so a huge log cannot be loaded in full. An absent log yields an empty string (not an error).
func (*NativeProcessProvider) Remove ¶ added in v0.10.0
func (p *NativeProcessProvider) Remove(ctx context.Context, slug string) error
Remove stops the service, deletes its per-slug directory (binary + logs), and drops its registry entry — the native analogue of removing a container and its volumes.
func (*NativeProcessProvider) Restart ¶ added in v0.10.0
func (p *NativeProcessProvider) Restart(ctx context.Context, slug string) error
Restart stops then starts the service.
func (*NativeProcessProvider) SetEventRecorder ¶ added in v0.10.0
func (p *NativeProcessProvider) SetEventRecorder(fn func(slug, event, detail string))
SetEventRecorder wires a lifecycle-event sink (typically store.RecordEvent) so the supervisor's autonomous crashes and respawns are recorded into the same event stream HealthScores aggregates. Call once at wiring time, before the first Deploy — it is read (without locking) only from supervise goroutines, which are created later by Deploy.
func (*NativeProcessProvider) Start ¶ added in v0.10.0
func (p *NativeProcessProvider) Start(ctx context.Context, slug string) error
Start (re)launches a previously-deployed service from the registry. It is a no-op if the service is already running (as our child or as a live orphan pid).
func (*NativeProcessProvider) Status ¶ added in v0.10.0
func (p *NativeProcessProvider) Status(ctx context.Context) Status
Status reports the native runtime as always available: unlike Docker it has no external dependency (no daemon/socket), so it can always run a native process.
func (*NativeProcessProvider) Stop ¶ added in v0.10.0
func (p *NativeProcessProvider) Stop(ctx context.Context, slug string) error
Stop stops the service: a managed child is signalled gracefully then killed after the grace period; an orphan pid recorded by a previous session is signalled by pid. It marks the registry entry as desired=stopped so List reports it stopped.
type Provider ¶
type Provider interface {
Status(ctx context.Context) Status
Deploy(ctx context.Context, spec DeploySpec, progress func(string)) (ContainerInfo, error)
Start(ctx context.Context, slug string) error
Stop(ctx context.Context, slug string) error
Restart(ctx context.Context, slug string) error
Remove(ctx context.Context, slug string) error
Logs(ctx context.Context, slug string, lines int) (string, error)
List(ctx context.Context) ([]ContainerInfo, error)
}
type Status ¶
type Status struct {
Available bool `json:"available"`
// NativeAvailable reports whether the always-on native process runtime is
// registered (and therefore available: it has no external dependency, no daemon
// or socket to reach). It is an ADDITIVE signal set by the app layer from the
// services manager — Available keeps its Docker-only meaning, which other code
// still reads — so onboarding can proceed on Docker OR native.
NativeAvailable bool `json:"nativeAvailable"`
Kind string `json:"kind"`
Message string `json:"message"`
Version string `json:"version"`
Context string `json:"context"`
Tools map[string]string `json:"tools"`
}