Documentation
¶
Overview ¶
Package agent contains the long-running daemon mode of the nuzur CLI.
The daemon holds a persistent LocalAgentChannel bidi stream open against the cloud connection-manager. The server drives reverse RPCs (Ping, RunQuery, etc.); the agent runs them locally and streams responses back.
Phase 2 supports Ping + RunQuery against a single hardcoded *sqlx.DB opened from NUZUR_AGENT_DSN. Phase 3+ adds the connection registry, OS keychain, multiple connections, transactions, row-value transport, and auto-install.
Package agent's install.go provides the platform-specific "auto-start at login" hooks. macOS uses launchd's per-user LaunchAgents; Linux uses systemd --user units. Windows is intentionally left out for now — Task Scheduler XML is verbose enough that it warrants a dedicated pass.
Index ¶
Constants ¶
const CapPgLiveSchemaSource = "pg_live_schema_source"
CapPgLiveSchemaSource tells the server this agent can introspect its own Postgres database for the "existing" side of a schema diff, so the cloud doesn't have to ship a reconstructed create.sql (which loses whatever the project-version model can't express, producing migrations that never converge).
Must match the constant in nuzur-go's connection-manager/module/sql-connection-manager.
const DefaultMaxConcurrentQueries = 32
DefaultMaxConcurrentQueries is the safety cap that ships when neither the flag nor env is set. It's well above the per-connection driver pool (SetMaxOpenConns=5) so normal workloads never see it, but small enough that a runaway client can't spawn thousands of waiting goroutines.
Variables ¶
var ErrCLITooOld = errors.New("nuzur CLI is too old; update and restart the agent")
ErrCLITooOld is returned by Run() when the server's Welcome carries a min_cli_version higher than this CLI's CLI_VERSION. Callers should NOT retry — the failure will repeat on every reconnect until the user updates their CLI binary.
Functions ¶
Types ¶
type DaemonOptions ¶
type DaemonOptions struct {
// ConnectionManagerAddress overrides the cloud endpoint; otherwise the
// constant / NUZUR_CONNECTION_MANAGER_ADDRESS env var is used.
ConnectionManagerAddress *string
DisableTLS bool
// LocalDB describes the single hardcoded database the agent answers
// RunQuery against in phase 2. The `start` command is responsible for
// resolving these (flag → env → saved file → interactive prompt) and
// passing them in. Empty DSN is allowed — the daemon will run but
// every RunQuery returns an error.
Driver string
DSN string
// MaxConcurrentQueries caps the number of DB-touching reverse RPCs the
// agent runs simultaneously. <=0 disables the cap. The default applied
// by Run() is DefaultMaxConcurrentQueries when the field is zero.
MaxConcurrentQueries int
}
DaemonOptions configures one run of the daemon's main loop.
type InstallResult ¶
InstallResult describes where the service file landed so the caller (the `nuzur-cli agent install` command) can print something useful.
func Install ¶
func Install() (*InstallResult, error)
Install writes the platform-appropriate service definition and loads it so the daemon starts immediately and survives reboots.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package connections holds the agent's local registry of database connections — the set of named (name, driver, DSN, db_type) entries the user has added via `nuzur-cli agent connection add`.
|
Package connections holds the agent's local registry of database connections — the set of named (name, driver, DSN, db_type) entries the user has added via `nuzur-cli agent connection add`. |