runtime

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package runtime manages the Patchcord agent's lifecycle: opening its database, launching and supervising its installed plugins, binding its local HTTP API, and shutting everything down cleanly on cancellation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent supervises the agent's database, HTTP API and installed plugins for the duration of one run.

func NewAgent

func NewAgent(cfg Config, logger *slog.Logger) (*Agent, error)

NewAgent opens and migrates the agent's database, launches and starts supervising its installed plugins, then binds its listen address and prepares its HTTP server. It returns an error if the database or the listen address cannot be set up; a plugin that fails to launch is logged and skipped, never fails agent startup (see plugins.Supervisor).

func (*Agent) Addr

func (a *Agent) Addr() string

Addr returns the actual address the agent is listening on. It is only meaningful after NewAgent has succeeded.

func (*Agent) Run

func (a *Agent) Run(ctx context.Context) error

Run serves the agent's HTTP API until ctx is cancelled, then shuts it down gracefully within the configured shutdown timeout before stopping its plugin supervisor and closing the database. It blocks until the agent has fully stopped.

type Config

type Config struct {
	// ListenAddr is the local address the HTTP API binds to, e.g. "127.0.0.1:7331".
	ListenAddr string
	// DataDir holds the agent's SQLite database, created if it doesn't exist.
	DataDir string
	// SecretsMasterKeyFile points to the file holding the base64 AES-256
	// master key for the "file" secret store. Left empty, "file" secret
	// references simply don't resolve on this agent — see
	// secrets.BuildStore and ADR-0040.
	SecretsMasterKeyFile string
	// AppsDirectoryListingEnabled turns on GET /apps/, an index page listing
	// every installed application. Left false (the default), that route
	// keeps returning a plain 404 — see ADR-0061.
	AppsDirectoryListingEnabled bool
	// ShutdownTimeout bounds how long in-flight requests are given to
	// complete once shutdown starts. Defaults to 10s when zero.
	ShutdownTimeout time.Duration
}

Config holds the settings needed to run the agent.

Jump to

Keyboard shortcuts

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