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 ¶
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
// Forget drops a remembered stopped instance so it no longer appears on
// the dashboard. Only registry-backed (fully stopped standalone)
// instances have an entry; anything else is discovery.ErrNotFound.
Forget(ctx context.Context, key string) 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) 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.