procmon

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 8 Imported by: 0

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

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

func NewManager(database *db.DB, heartbeatInterval time.Duration) *Manager

NewManager creates a new process manager.

func (*Manager) CleanupStaleProcessRecords

func (m *Manager) CleanupStaleProcessRecords(ctx context.Context) error

CleanupStaleProcessRecords removes database records for processes with stale heartbeats. This should be called periodically by a cleanup routine.

func (*Manager) GetAllProcesses

func (m *Manager) GetAllProcesses(ctx context.Context) ([]*db.Process, error)

GetAllProcesses retrieves all registered processes.

func (*Manager) GetControlPlaneProcess

func (m *Manager) GetControlPlaneProcess(ctx context.Context) (*db.Process, error)

GetControlPlaneProcess retrieves the control plane process.

func (*Manager) GetOrchestratorProcess

func (m *Manager) GetOrchestratorProcess(ctx context.Context, workID string) (*db.Process, error)

GetOrchestratorProcess retrieves the orchestrator process for a work ID.

func (*Manager) IsControlPlaneAlive

func (m *Manager) IsControlPlaneAlive(ctx context.Context) (bool, error)

IsControlPlaneAlive checks if the control plane has a recent heartbeat.

func (*Manager) IsOrchestratorAlive

func (m *Manager) IsOrchestratorAlive(ctx context.Context, workID string) (bool, error)

IsOrchestratorAlive checks if an orchestrator for the given work ID has a recent heartbeat.

func (*Manager) RegisterControlPlane

func (m *Manager) RegisterControlPlane(ctx context.Context) error

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

func (m *Manager) RegisterOrchestrator(ctx context.Context, workID string) error

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

func (m *Manager) SetNowFunc(f func() time.Time)

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

func (m *Manager) TriggerHeartbeat() error

TriggerHeartbeat forces an immediate heartbeat update and waits for it to complete. This is primarily for testing purposes to avoid time-based sleeps.

Jump to

Keyboard shortcuts

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