monitor

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExitInfo

type ExitInfo struct {
	Code      int
	Signal    string
	Timestamp time.Time
	Error     error
}

ExitInfo contains information about process exit

type HealthCheck

type HealthCheck struct {
	Endpoint  string
	Status    HealthStatus
	Latency   time.Duration
	Error     error
	Timestamp time.Time
}

HealthCheck represents a health check result

type HealthMonitor

type HealthMonitor struct {
	// contains filtered or unexported fields
}

HealthMonitor monitors the health of the core service

func NewHealthMonitor

func NewHealthMonitor(endpoint string, logger *zap.SugaredLogger, stateMachine *state.Machine) *HealthMonitor

NewHealthMonitor creates a new health monitor

func (*HealthMonitor) GetLastCheck

func (hm *HealthMonitor) GetLastCheck() time.Time

GetLastCheck returns the time of the last health check

func (*HealthMonitor) GetLastError

func (hm *HealthMonitor) GetLastError() error

GetLastError returns the last health check error

func (*HealthMonitor) GetStatus

func (hm *HealthMonitor) GetStatus() HealthStatus

GetStatus returns the current health status

func (*HealthMonitor) IsHealthy

func (hm *HealthMonitor) IsHealthy() bool

IsHealthy returns true if the service is healthy

func (*HealthMonitor) IsReady

func (hm *HealthMonitor) IsReady() bool

IsReady returns true if the service is ready

func (*HealthMonitor) IsStarting

func (hm *HealthMonitor) IsStarting() bool

IsStarting returns true if the service is starting up

func (*HealthMonitor) ResultsChannel

func (hm *HealthMonitor) ResultsChannel() <-chan HealthCheck

ResultsChannel returns a channel for receiving health check results

func (*HealthMonitor) SetCheckInterval

func (hm *HealthMonitor) SetCheckInterval(interval time.Duration)

SetCheckInterval sets the health check interval

func (*HealthMonitor) SetReadinessTimeout

func (hm *HealthMonitor) SetReadinessTimeout(timeout time.Duration)

SetReadinessTimeout sets the readiness wait timeout

func (*HealthMonitor) SetTimeout

func (hm *HealthMonitor) SetTimeout(timeout time.Duration)

SetTimeout sets the health check timeout

func (*HealthMonitor) Start

func (hm *HealthMonitor) Start()

Start starts the health monitoring

func (*HealthMonitor) Stop

func (hm *HealthMonitor) Stop()

Stop stops the health monitoring (safe to call multiple times)

func (*HealthMonitor) WaitForReady

func (hm *HealthMonitor) WaitForReady() error

WaitForReady waits for the service to become ready within the timeout

type HealthStatus

type HealthStatus string

HealthStatus represents the health status of the core service

const (
	HealthStatusUnknown     HealthStatus = "unknown"
	HealthStatusStarting    HealthStatus = "starting"
	HealthStatusHealthy     HealthStatus = "healthy"
	HealthStatusUnhealthy   HealthStatus = "unhealthy"
	HealthStatusUnavailable HealthStatus = "unavailable"
)

type ProcessConfig

type ProcessConfig struct {
	Binary        string
	Args          []string
	Env           []string
	WorkingDir    string
	StartTimeout  time.Duration
	CaptureOutput bool
}

ProcessConfig contains configuration for process monitoring

type ProcessEvent

type ProcessEvent struct {
	Type      ProcessEventType
	Data      map[string]interface{}
	Error     error
	Timestamp time.Time
}

ProcessEvent represents events from the process monitor

type ProcessEventType

type ProcessEventType string
const (
	ProcessEventStarted ProcessEventType = "started"
	ProcessEventExited  ProcessEventType = "exited"
	ProcessEventError   ProcessEventType = "error"
	ProcessEventOutput  ProcessEventType = "output"
)

type ProcessMonitor

type ProcessMonitor struct {
	// contains filtered or unexported fields
}

ProcessMonitor monitors a subprocess and reports its status

func NewProcessMonitor

func NewProcessMonitor(config *ProcessConfig, logger *zap.SugaredLogger, stateMachine *state.Machine) *ProcessMonitor

NewProcessMonitor creates a new process monitor

func (*ProcessMonitor) EventChannel

func (pm *ProcessMonitor) EventChannel() <-chan ProcessEvent

EventChannel returns a channel for receiving process events

func (*ProcessMonitor) GetExitInfo

func (pm *ProcessMonitor) GetExitInfo() *ExitInfo

GetExitInfo returns information about process exit

func (*ProcessMonitor) GetOutput

func (pm *ProcessMonitor) GetOutput() (stdout, stderr string)

GetOutput returns captured stdout and stderr

func (*ProcessMonitor) GetPID

func (pm *ProcessMonitor) GetPID() int

GetPID returns the process ID

func (*ProcessMonitor) GetStatus

func (pm *ProcessMonitor) GetStatus() ProcessStatus

GetStatus returns the current process status

func (*ProcessMonitor) Shutdown

func (pm *ProcessMonitor) Shutdown()

Shutdown gracefully shuts down the process monitor

func (*ProcessMonitor) Start

func (pm *ProcessMonitor) Start() error

Start starts the monitored process

func (*ProcessMonitor) Stop

func (pm *ProcessMonitor) Stop() error

Stop stops the monitored process

type ProcessStatus

type ProcessStatus string

ProcessStatus represents the status of a monitored process

const (
	ProcessStatusStopped  ProcessStatus = "stopped"
	ProcessStatusStarting ProcessStatus = "starting"
	ProcessStatusRunning  ProcessStatus = "running"
	ProcessStatusFailed   ProcessStatus = "failed"
	ProcessStatusCrashed  ProcessStatus = "crashed"
)

Jump to

Keyboard shortcuts

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