loop

package
v0.0.0-...-1d32ed5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package loop contains the main daemon event loop: connect to relay, dispatch incoming messages to the session manager, run periodic heartbeats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

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

Daemon is the running daemon state.

func New

func New(cfg *config.Config, version string) (*Daemon, error)

New constructs a Daemon that runs tasks through Pi.

func NewWithPiBinaryPath

func NewWithPiBinaryPath(cfg *config.Config, version, piBinaryOverride string) (*Daemon, error)

NewWithPiBinaryPath constructs a Daemon with an optional Pi binary override. Used by integration tests to inject a fake Pi process.

func (*Daemon) Health

func (d *Daemon) Health() sockapi.HealthData

Health implements sockapi.StatusProvider.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

Run connects to the relay and blocks until ctx is canceled. The client handles reconnection automatically.

func (*Daemon) Sessions

func (d *Daemon) Sessions() []sockapi.SessionInfo

Sessions implements sockapi.StatusProvider.

func (*Daemon) Status

func (d *Daemon) Status() sockapi.StatusData

Status implements sockapi.StatusProvider.

func (*Daemon) Workers

func (d *Daemon) Workers() []sockapi.WorkerInfo

type SessionManager

type SessionManager interface {
	Get(sessionID string) *session.Actor
	Spawn(ctx context.Context, opts session.Options) (*session.Actor, error)
	ActiveTaskIDs() []string
	ActiveCount() (total int, executing int)
	InFlightCount() int
	StartReaper(ctx context.Context, tick time.Duration, maxIdle time.Duration)
	StartWorkerReaper(ctx context.Context, tick time.Duration, maxIdle time.Duration, idleCap int)
	StopAll()
	SessionInfos() []sockapi.SessionInfo
	WorkerSnapshots() []pi.WorkerSnapshot
}

SessionManager is the interface the Daemon uses to interact with session actors.

Jump to

Keyboard shortcuts

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