Documentation
¶
Overview ¶
Package orbit is the pluggable admin product for the Nucleus framework.
Orbit is a separate Go module that mounts in-process into a Nucleus application via the framework's extension/module API, and serves a self-contained admin UI (Data Studio, live request/SQL feed, session viewer, RBAC, system metrics). It was extracted from the framework core per nucleus ADR-019 so it can ship, version, and evolve as its own product while the core stays lean. Mount it explicitly:
app, err := nucleus.New().
FromConfigFile("nucleus.yml").
Mount(orbit.Module(orbit.Config{Prefix: "/admin"})).
Build()
Orbit reads everything it needs from the nucleus Runtime — the model registry, the managed database handles, the session manager, the RBAC enforcer, the live event bus, storage (the accessors added in nucleus ADR-019 Slice 1/2) — so it never reaches into the framework's internals.
Index ¶
Constants ¶
const DefaultPrefix = "/admin"
DefaultPrefix is the URL path orbit mounts under when Config.Prefix is empty.
Variables ¶
This section is empty.
Functions ¶
func Module ¶
func Module(cfg Config) nucleus.ModuleSpec
Module returns orbit as a nucleus ModuleSpec, mountable on an application via the builder's Mount(...). It is self-contained: it declares its own URL prefix and acquires every framework service it needs from the Runtime in OnStart, then mounts the admin panel's own router under the prefix in Routes.
Types ¶
type Config ¶
type Config struct {
// Prefix is the URL path orbit mounts under (default DefaultPrefix).
Prefix string `yaml:"prefix" koanf:"prefix"`
// Title is the heading shown in the admin UI.
Title string `yaml:"title" koanf:"title"`
// Bootstrap admin user, created on first start if it does not exist. When
// BootstrapPassword is empty, bootstrapping is skipped (the operator is
// expected to provision the admin user another way).
BootstrapUsername string `yaml:"bootstrap_username" koanf:"bootstrap_username"`
BootstrapEmail string `yaml:"bootstrap_email" koanf:"bootstrap_email"`
BootstrapPassword string `yaml:"bootstrap_password" koanf:"bootstrap_password"`
// AuthDatabase optionally names a managed database alias whose handle backs
// admin authentication and the bootstrap user. Empty means use the default
// database. The panel itself (Data Studio etc.) always runs on the default
// handle; only the auth/bootstrap *sql.DB is redirected.
AuthDatabase string `yaml:"auth_database" koanf:"auth_database"`
// Multi-tenant: set these to match the host application so Data Studio is
// confined to the tenant the app resolves for each request (list, get,
// create, update, delete, bulk, exports, imports, fixtures). Only a
// superuser or a subject granted the tenant_switch RBAC action can look at
// another tenant (?tenant=<id>) or at all of them (?tenant=all), and every
// switch is audited. Leave disabled for single-tenant apps.
MultiTenantEnabled bool `yaml:"multitenant_enabled" koanf:"multitenant_enabled"`
MultiTenantDefault string `yaml:"multitenant_default" koanf:"multitenant_default"`
MultiTenantIDs []string `yaml:"multitenant_ids" koanf:"multitenant_ids"`
// Environment is a label shown in the UI (e.g. "production"). Optional.
Environment string `yaml:"environment" koanf:"environment"`
// MigrationsPath is the directory the migrations view reads (default "migrations").
MigrationsPath string `yaml:"migrations_path" koanf:"migrations_path"`
// AuditMaxSize caps the in-memory audit log ring buffer; zero or negative
// means the default of 10000 entries.
AuditMaxSize int `yaml:"audit_max_size" koanf:"audit_max_size"`
// LiveExcludePatterns lists path patterns excluded from the live HTTP
// capture feed (e.g. health checks, the admin's own polling endpoints).
LiveExcludePatterns []string `yaml:"live_exclude_patterns" koanf:"live_exclude_patterns"`
// ClusterEnabled turns on cluster-aware live telemetry: live request/SQL
// events are relayed between nodes over Redis so the feed shows the whole
// fleet, not just the local node. Best-effort — a relay failure never blocks
// startup.
ClusterEnabled bool `yaml:"cluster_enabled" koanf:"cluster_enabled"`
// ClusterRedisURL is the Redis URL backing the live telemetry relay.
ClusterRedisURL string `yaml:"cluster_redis_url" koanf:"cluster_redis_url"`
// ClusterChannel is the Redis pub/sub channel the relay publishes on
// (default nucleus:admin:live:v1).
ClusterChannel string `yaml:"cluster_channel" koanf:"cluster_channel"`
// ClusterNodeID is an explicit node identifier for this instance in the
// relay (defaults to the runtime identity).
ClusterNodeID string `yaml:"cluster_node_id" koanf:"cluster_node_id"`
// ClusterToken is a shared secret the relay uses to reject untrusted
// (cross-tenant or spoofed) messages on the channel.
ClusterToken string `yaml:"cluster_token" koanf:"cluster_token"`
// TraceURLTemplate is an external trace-explorer URL template surfaced in
// the UI; it supports a {trace_id} placeholder.
TraceURLTemplate string `yaml:"trace_url_template" koanf:"trace_url_template"`
// DataSource overrides the source Data Studio browses and edits (ADR-001).
// Nil means the default: a Nucleus-backed adapter over the application's
// model registry and database handles. Set it to browse another backend —
// e.g. an app that runs the Quark ORM passes a quarkdatasource adapter
// (QADR-0006, Caso 2). Go-only wiring; not bindable from YAML. When set,
// the runtime field-metadata editor is disabled (it mutates the Nucleus
// registry, which a custom source does not necessarily have).
DataSource datasource.DataSource `yaml:"-" koanf:"-"`
}
Config configures the orbit admin module. The zero value is valid (orbit mounts under DefaultPrefix); bound from the `modules.orbit.*` subtree of the application config when mounted on a config-file app.
The struct is flat, but its fields serve two different modes — do not let the cluster vocabulary scare a plain panel setup:
- Panel (what almost every app uses): Prefix, Title, Bootstrap*, AuthDatabase, MultiTenant*, Environment, MigrationsPath, AuditMaxSize, LiveExcludePatterns, TraceURLTemplate. Nothing else is required; the four-field examples/minimal is a complete production shape.
- Cluster live-feed relay (opt-in, off by default): the Cluster* fields. They only matter once ClusterEnabled is true; in particular, NO Redis is needed to run the panel — ClusterRedisURL is read exclusively by the relay. The standalone fleet plane (agent/, server/) is configured on its own binaries, not here.
- Go-only: DataSource (not bindable from YAML).
Grouping the Cluster* fields into a nested sub-struct would make this split structural, but the flat yaml keys (cluster_enabled, ...) are part of the frozen surface below, so that reshuffle is deliberately deferred to a hypothetical v2; within v1.x the split lives in this comment and in the configuration docs.
Config is a frozen v1.0 surface (docs/V1_GATE.md §A-3): every field keeps its name, yaml key, type, and zero-value behavior for the life of v1.x. Fields may be added; none is removed or renamed without a major. The freeze is enforced by contracts/freeze_test.go.
Directories
¶
| Path | Synopsis |
|---|---|
|
agent
module
|
|
|
Package datasource is Orbit's neutral, backend-agnostic contract for Data Studio (ADR-001).
|
Package datasource is Orbit's neutral, backend-agnostic contract for Data Studio (ADR-001). |
|
examples
|
|
|
minimal
command
Command minimal is the smallest runnable Orbit example: a Nucleus app with the in-process admin panel (orbit.Module) mounted at /admin.
|
Command minimal is the smallest runnable Orbit example: a Nucleus app with the in-process admin panel (orbit.Module) mounted at /admin. |
|
internal
|
|
|
admin
Package admin provides an auto-generated administration panel for Nucleus, similar to Django's contrib.admin.
|
Package admin provides an auto-generated administration panel for Nucleus, similar to Django's contrib.admin. |
|
datasource/nucleus
Package nucleus is the Nucleus-backed implementation of Orbit's neutral datasource contract (ADR-001).
|
Package nucleus is the Nucleus-backed implementation of Orbit's neutral datasource contract (ADR-001). |
|
proto
module
|
|
|
quarkbridge
module
|
|
|
quarkdatasource
module
|
|
|
server
module
|