Documentation
¶
Overview ¶
Package lifecycle starts, stops and restarts discovered Dapr applications and their sidecars. Compose instances act on containers via the container runtime; standalone (dapr run) instances signal processes and re-run captured commands. An in-memory registry keeps standalone instances the dashboard stopped visible until they are started again.
Index ¶
- Variables
- func Overlay(inner discovery.Service, reg *Registry, proc ProcController) discovery.Service
- func ValidAction(a Action) bool
- func ValidTarget(t Target) bool
- type Action
- type Entry
- type Manager
- type ProcController
- type ProcSnapshot
- type Registry
- func (r *Registry) Drop(key string)
- func (r *Registry) DropTarget(key string, t Target)
- func (r *Registry) Get(key string) (Entry, bool)
- func (r *Registry) IsSuppressed(key string) bool
- func (r *Registry) List() []Entry
- func (r *Registry) RecordStop(in discovery.Instance, snaps map[Target]ProcSnapshot)
- func (r *Registry) Suppress(key string)
- func (r *Registry) Unsuppress(key string)
- type Starter
- type Target
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Overlay ¶
Overlay decorates a discovery.Service with the stopped-app registry: partially stopped live instances get their statuses corrected, and fully stopped instances (invisible to the process scan) are appended from their stop-time snapshots. Compose instances never hit the registry — stopped containers are discovered natively.
func ValidAction ¶
func ValidTarget ¶
Types ¶
type Entry ¶
type Entry struct {
Instance discovery.Instance
Procs map[Target]ProcSnapshot
}
Entry is one stopped (fully or partially) standalone instance.
type Manager ¶
type Manager interface {
Do(ctx context.Context, key string, target Target, action Action) error
// Dismiss hides an inactive instance from the dashboard: it drops any
// registry ghost and suppresses the InstanceKey so a natively-scanned
// stopped instance (e.g. a stopped compose container) stops appearing.
// The suppression auto-clears when the instance is seen running again.
// It always succeeds and never touches Docker.
Dismiss(ctx context.Context, key string) error
// ClearInactive dismisses every currently fully-stopped instance and
// returns how many distinct instances were dismissed.
ClearInactive(ctx context.Context) (int, error)
}
Manager starts, stops and restarts discovered app instances.
func New ¶
func New(apps discovery.Service, reg *Registry, run containerruntime.Runner, proc ProcController, start Starter) Manager
New builds the Manager. run may be nil (no container runtime): compose actions then fail with ErrRuntimeUnavailable.
type ProcController ¶
type ProcController interface {
Snapshot(pid int) (ProcSnapshot, error)
Terminate(pid int) error
Kill(pid int) error
Alive(pid int) bool
}
ProcController isolates OS process operations so the manager is testable.
func NewProcController ¶
func NewProcController() ProcController
NewProcController returns the gopsutil-backed ProcController.
type ProcSnapshot ¶
type ProcSnapshot struct {
PID int
Argv []string
Dir string
LogPath string // stdout/stderr destination for the re-run; "" discards
}
ProcSnapshot captures what is needed to re-run a stopped process.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the in-memory record of instances the dashboard stopped. It is intentionally not persisted: after a dashboard restart the processes are genuinely gone and unknowable.
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) DropTarget ¶
DropTarget removes one target's snapshot; the entry disappears with its last target.
func (*Registry) IsSuppressed ¶ added in v0.0.17
IsSuppressed reports whether key is currently suppressed.
func (*Registry) RecordStop ¶
func (r *Registry) RecordStop(in discovery.Instance, snaps map[Target]ProcSnapshot)
RecordStop merges snaps into the entry for in's InstanceKey, storing in as the display snapshot.
func (*Registry) Suppress ¶ added in v0.0.17
Suppress hides an InstanceKey from the overlay while it remains fully stopped. It is cleared automatically when the instance is seen running again (see overlay.List) or on dashboard restart (the set is not persisted).
func (*Registry) Unsuppress ¶ added in v0.0.17
Unsuppress removes a key from the suppression set.