Documentation
¶
Overview ¶
Package compose defines SystemForge's composition runtime: the Feature and Registrar contracts that let capabilities — a single feature slice or a whole application — be composed into one binary or split across services without changing the capabilities themselves.
A Feature registers its HTTP routes through a Registrar and participates in a Start/Stop lifecycle. An App (see app.go) aggregates Features and is itself a Feature, which makes composition recursive: a host registers a whole application the same way an application registers one of its own features.
See docs/architecture/systemforge-application-architecture.md for the conventions this package implements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App composes Features into one unit. App is itself a Feature, so an application can be embedded into a larger host composition — this is what makes SystemForge composition recursive.
An App is built during startup (before serving) and is not safe for concurrent modification.
func (*App) RegisterRoutes ¶
RegisterRoutes registers every feature's routes in registration order, stopping at the first error.
type Base ¶
type Base struct{}
Base can be embedded in a Feature to satisfy the lifecycle methods with no-ops, so small features only implement Name and RegisterRoutes.
type Feature ¶
type Feature interface {
// Name returns the capability's canonical slug (see the application
// architecture guide). It must be stable and unique within a composition.
Name() string
// RegisterRoutes registers the capability's HTTP routes via the Registrar.
RegisterRoutes(r Registrar) error
// Start performs startup work (warming caches, opening consumers, etc.).
// It may be a no-op.
Start(ctx context.Context) error
// Stop releases resources acquired in Start. It may be a no-op.
Stop(ctx context.Context) error
}
Feature is one registrable capability: a feature slice or a whole app.
Implementations that have no startup/shutdown work can embed Base to get no-op Start/Stop and only implement Name and RegisterRoutes.
type Registrar ¶
type Registrar interface {
// HumaAPI returns the Huma API for typed operation registration.
HumaAPI() huma.API
// Mux returns the underlying chi router for not-yet-migrated handlers.
Mux() chi.Router
}
Registrar is the registration surface a Feature receives. It abstracts the HTTP layer so a feature registers routes without constructing the server.
SystemForge is mid-migration from chi handlers to Huma operations, so the Registrar exposes both: HumaAPI for typed operation registration (the forward direction) and Mux for chi handlers not yet migrated. A feature should prefer HumaAPI for new endpoints.