observer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyRunning = errors.New("observer is already running")
)

Functions

This section is empty.

Types

type CatalogEntry

type CatalogEntry struct {
	Harness       registry.Harness `json:"harness"`
	SessionID     string           `json:"session_id,omitempty"`
	SessionPath   string           `json:"session_path,omitempty"`
	ResumeCommand []string         `json:"resume_command,omitempty"`
	CWD           string           `json:"cwd,omitempty"`
	ProjectRoot   string           `json:"project_root,omitempty"`
	ProcessPID    int              `json:"process_pid,omitempty"`
	Current       bool             `json:"current"`
}

func DefaultCatalogList

func DefaultCatalogList(ctx context.Context) ([]CatalogEntry, error)

DefaultCatalogList reads the optional machine-readable catalog configured by AHT_CATALOG_JSON or AHT_CATALOG_FILE. The payload is either an array of catalog entries or an object with a sessions array.

type CatalogLister

type CatalogLister func(context.Context) ([]CatalogEntry, error)

type Health

type Health struct {
	PID                          int           `json:"pid"`
	StartIdentity                string        `json:"start_identity,omitempty"`
	Interval                     time.Duration `json:"interval"`
	GracePeriod                  time.Duration `json:"grace_period"`
	StartedAt                    time.Time     `json:"started_at"`
	LastAttemptAt                time.Time     `json:"last_attempt_at"`
	LastSuccessAt                time.Time     `json:"last_success_at"`
	LastEnumerationErrorCategory string        `json:"last_enumeration_error_category,omitempty"`
	LastEnumerationError         string        `json:"last_enumeration_error,omitempty"`
	Cycles                       int           `json:"cycles"`
	Observations                 int           `json:"observations"`
	Sessions                     int           `json:"sessions"`
	Degraded                     bool          `json:"degraded"`
}

type Observer

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

func New

func New(options Options) *Observer

func (*Observer) Health

func (o *Observer) Health() Health

func (*Observer) Run

func (o *Observer) Run(ctx context.Context) error

func (*Observer) RunOnce

func (o *Observer) RunOnce(ctx context.Context) (Result, error)

func (*Observer) RunWithResults

func (o *Observer) RunWithResults(ctx context.Context, handle func(Result) error) error

RunWithResults runs the observer and calls handle after every reconciliation cycle. It is used by foreground clients that stream cycle results.

type Options

type Options struct {
	Store                    registry.Store
	StorePath                string
	Interval                 time.Duration
	GracePeriod              time.Duration
	HealthPath               string
	ProcessList              ProcessLister
	PaneList                 PaneLister
	CatalogList              CatalogLister
	ScreenCapture            ScreenCapturer
	MultiplexerPaneList      muxctx.PaneLister
	MultiplexerScreenCapture muxctx.ScreenCapturer
	DetectionConfigDir       string
	Now                      func() time.Time
	ErrorWriter              io.Writer
	Quiet                    bool
}

type PaneLister

type PaneLister func(context.Context) ([]tmuxctx.Pane, error)

type ProcessLister

type ProcessLister func(context.Context) ([]processinfo.Process, error)

type Result

type Result struct {
	ObservedAt   time.Time `json:"observed_at"`
	Observations int       `json:"observations"`
	Sessions     int       `json:"sessions"`
	Processes    int       `json:"processes"`
	Panes        int       `json:"panes"`
	Catalog      int       `json:"catalog"`
	Present      int       `json:"present"`
	Gone         int       `json:"gone"`
	Changed      int       `json:"changed"`
	Degraded     bool      `json:"degraded"`
	Error        string    `json:"error,omitempty"`
}

func (Result) String

func (r Result) String() string

type ScreenCapturer

type ScreenCapturer func(context.Context, tmuxctx.Pane) (tmuxctx.ScreenSnapshot, error)

Jump to

Keyboard shortcuts

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