Documentation
¶
Overview ¶
Package procmon provides process monitoring via database-backed heartbeats. It enables detection of hung processes (alive but not making progress) via stale heartbeats.
Index ¶
- type Manager
- func (m *Manager) CleanupStaleProcessRecords(ctx context.Context) error
- func (m *Manager) GetAllProcesses(ctx context.Context) ([]*db.Process, error)
- func (m *Manager) GetControlPlaneProcess(ctx context.Context) (*db.Process, error)
- func (m *Manager) GetOrchestratorProcess(ctx context.Context, workID string) (*db.Process, error)
- func (m *Manager) IsControlPlaneAlive(ctx context.Context) (bool, error)
- func (m *Manager) IsOrchestratorAlive(ctx context.Context, workID string) (bool, error)
- func (m *Manager) RegisterControlPlane(ctx context.Context) error
- func (m *Manager) RegisterOrchestrator(ctx context.Context, workID string) error
- func (m *Manager) SetNowFunc(f func() time.Time)
- func (m *Manager) Stop()
- func (m *Manager) TriggerHeartbeat() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles process registration, heartbeat updates, and cleanup.
func NewManager ¶
NewManager creates a new process manager.
func (*Manager) CleanupStaleProcessRecords ¶
CleanupStaleProcessRecords removes database records for processes with stale heartbeats. This should be called periodically by a cleanup routine.
func (*Manager) GetAllProcesses ¶
GetAllProcesses retrieves all registered processes.
func (*Manager) GetControlPlaneProcess ¶
GetControlPlaneProcess retrieves the control plane process.
func (*Manager) GetOrchestratorProcess ¶
GetOrchestratorProcess retrieves the orchestrator process for a work ID.
func (*Manager) IsControlPlaneAlive ¶
IsControlPlaneAlive checks if the control plane has a recent heartbeat.
func (*Manager) IsOrchestratorAlive ¶
IsOrchestratorAlive checks if an orchestrator for the given work ID has a recent heartbeat.
func (*Manager) RegisterControlPlane ¶
RegisterControlPlane registers this process as the control plane. Any existing stale control plane record is cleaned up first. Returns an error if registration fails.
func (*Manager) RegisterOrchestrator ¶
RegisterOrchestrator registers this process as an orchestrator for the given work ID. Any existing stale orchestrator record for this work ID is cleaned up first. Returns an error if registration fails.
func (*Manager) SetNowFunc ¶
SetNowFunc sets the time function used for heartbeat updates. This is primarily for testing purposes.
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop gracefully shuts down the manager and unregisters the process.
func (*Manager) TriggerHeartbeat ¶
TriggerHeartbeat forces an immediate heartbeat update and waits for it to complete. This is primarily for testing purposes to avoid time-based sleeps.