Documentation
¶
Overview ¶
Package togo is the microkernel of the togo framework. The kernel is deliberately thin: configuration, a hook/event bus, a plugin loader+registry, a database pool, and server bootstrap. Every capability — REST, GraphQL, auth, dashboard, resources — ships as a Plugin installed by the CLI and discovered here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Addr string
DatabaseURL string
GraphQLPath string
RESTPath string
DocsPath string
}
Config holds runtime configuration resolved from the environment, so connections/URLs/endpoints stay dynamic (togo convention: .env + hooks).
func LoadConfig ¶
func LoadConfig() *Config
LoadConfig reads configuration from environment variables with sane defaults.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks is a priority-ordered event bus for lifecycle events (resource CRUD, auth, plugin load). Listeners run in ascending priority (0 first).
type Kernel ¶
type Kernel struct {
Config *Config
Router chi.Router
Hooks *Hooks
// contains filtered or unexported fields
}
Kernel is the shared runtime handed to every plugin and used by the app's entrypoint to mount REST/GraphQL and serve.
func New ¶
func New() *Kernel
New constructs a kernel: loads config, creates the router and hook bus, and seeds the plugin list from auto-discovery (blank-imported plugin packages).
func (*Kernel) Boot ¶
Boot runs Register then Boot for every plugin in priority order. Safe to call once; subsequent calls are no-ops.
func (*Kernel) DB ¶
DB returns a lazily-opened Postgres pool from Config.DatabaseURL. Any database driver is supported via the connection string; Postgres (pgx) is the default.
type Plugin ¶
type Plugin interface {
// Name uniquely identifies the plugin (e.g. "rest-huma", "auth-supabase").
Name() string
// Priority controls boot order; lower boots first. Infrastructure plugins
// (config, db) use low values; feature plugins use higher ones.
Priority() int
// Register binds services, config, and hooks. No I/O or route mounting here.
Register(k *Kernel) error
// Boot starts the plugin: mount routes, register schema, run migrations.
Boot(ctx context.Context, k *Kernel) error
}
Plugin is the contract every togo capability implements. The runtime boots plugins in ascending Priority order (0–100), mirroring laravilt's ordered service-provider lifecycle.
func Discovered ¶
func Discovered() []Plugin
Discovered returns a copy of the auto-registered plugins.