Documentation
¶
Overview ¶
Package app wires platforms, routing, middleware, plugins and storage into a runtime.
Index ¶
- Variables
- type App
- func (a *App) AppMigrations(m ...plugin.Migration)
- func (a *App) AutoPluginMigrationsFromStorage()
- func (a *App) AutoPluginSettingsFromStorage()
- func (a *App) Cache(c cache.Cache)
- func (a *App) CacheStore() cache.Cache
- func (a *App) Callback(pattern string, h middleware.Handler)
- func (a *App) Command(name string, h middleware.Handler)
- func (a *App) CommandPrefixes(prefixes ...string)
- func (a *App) CoreMigrations(m ...plugin.Migration)
- func (a *App) Dispatch(ctx context.Context, ev event.Event) (err error)
- func (a *App) DispatchWithPlatform(ctx context.Context, ev event.Event, p platform.Platform, ...) (err error)
- func (a *App) FSM(manager *fsm.Manager) *fsm.Manager
- func (a *App) Fallback(h middleware.Handler)
- func (a *App) Group(m ...middleware.Middleware) *Group
- func (a *App) Match(re *regexp.Regexp, h middleware.Handler)
- func (a *App) Message(h middleware.Handler)
- func (a *App) MigrateDown(ctx context.Context, steps int) (int, error)
- func (a *App) MigrateUp(ctx context.Context) (MigrationReport, error)
- func (a *App) MigrationPlan() []RuntimeMigration
- func (a *App) MigrationStatus(ctx context.Context) ([]MigrationStatus, error)
- func (a *App) On(t event.Type, h middleware.Handler)
- func (a *App) Platform(p platform.Platform)
- func (a *App) Plugin(p plugin.Plugin) error
- func (a *App) PluginMigrations(store plugin.MigrationStateStore)
- func (a *App) PluginSettings(store plugin.SettingsStateStore)
- func (a *App) Plugins() *plugin.Registry
- func (a *App) RateLimit(rule ratelimit.Rule)
- func (a *App) RuntimeSnapshot() RuntimeSnapshot
- func (a *App) SetLogger(logger *slog.Logger)
- func (a *App) Start(ctx context.Context) (err error)
- func (a *App) Storage(store storage.Store)
- func (a *App) Store() storage.Store
- func (a *App) Text(text string, h middleware.Handler)
- func (a *App) Use(m middleware.Middleware)
- type Group
- func (g *Group) Callback(pattern string, h middleware.Handler)
- func (g *Group) Command(name string, h middleware.Handler)
- func (g *Group) Fallback(h middleware.Handler)
- func (g *Group) Match(re *regexp.Regexp, h middleware.Handler)
- func (g *Group) Message(h middleware.Handler)
- func (g *Group) On(t event.Type, h middleware.Handler)
- func (g *Group) Text(text string, h middleware.Handler)
- func (g *Group) Use(m middleware.Middleware)
- type MigrationReport
- type MigrationStatus
- type PlatformSnapshot
- type RuntimeMigration
- type RuntimeSnapshot
- type RuntimeState
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRunning = errors.New("app is already running")
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Name string
Router *router.Router
Logger *slog.Logger
// contains filtered or unexported fields
}
App is the central AstraEngine runtime and registration surface.
func (*App) AppMigrations ¶
func (*App) AutoPluginMigrationsFromStorage ¶
func (a *App) AutoPluginMigrationsFromStorage()
func (*App) AutoPluginSettingsFromStorage ¶
func (a *App) AutoPluginSettingsFromStorage()
func (*App) CacheStore ¶
CacheStore returns the configured cache.
func (*App) CommandPrefixes ¶
CommandPrefixes sets the accepted text command prefixes. The default is "/".
func (*App) CoreMigrations ¶
func (*App) Dispatch ¶
Dispatch routes an event and records structured completion, error and panic logs.
func (*App) DispatchWithPlatform ¶
func (a *App) DispatchWithPlatform(ctx context.Context, ev event.Event, p platform.Platform, values map[string]any) (err error)
DispatchWithPlatform routes an event through an explicitly selected adapter. Values are copied so request handlers cannot mutate the caller's tenant metadata.
func (*App) FSM ¶
FSM injects centralized FSM manager middleware for all handlers. If manager is nil, a default in-memory user-scoped manager is created.
func (*App) Fallback ¶
func (a *App) Fallback(h middleware.Handler)
func (*App) Group ¶
func (a *App) Group(m ...middleware.Middleware) *Group
Group creates a route group with shared middleware.
func (*App) Message ¶
func (a *App) Message(h middleware.Handler)
func (*App) MigrationPlan ¶
func (a *App) MigrationPlan() []RuntimeMigration
func (*App) MigrationStatus ¶
func (a *App) MigrationStatus(ctx context.Context) ([]MigrationStatus, error)
func (*App) Platform ¶
Platform registers an adapter by its name and injects the application logger.
func (*App) PluginMigrations ¶
func (a *App) PluginMigrations(store plugin.MigrationStateStore)
func (*App) PluginSettings ¶
func (a *App) PluginSettings(store plugin.SettingsStateStore)
func (*App) RateLimit ¶
RateLimit adds a centralized rate-limit rule. The first call initializes and injects a shared limiter middleware.
func (*App) RuntimeSnapshot ¶ added in v2.0.1
func (a *App) RuntimeSnapshot() RuntimeSnapshot
RuntimeSnapshot returns a detached view of the application runtime.
func (*App) SetLogger ¶
SetLogger configures structured logging and propagates it to registered adapters.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group registers routes with an additional shared middleware chain.
func (*Group) Fallback ¶
func (g *Group) Fallback(h middleware.Handler)
func (*Group) Message ¶
func (g *Group) Message(h middleware.Handler)
func (*Group) Use ¶
func (g *Group) Use(m middleware.Middleware)
type MigrationReport ¶
type MigrationStatus ¶
type PlatformSnapshot ¶ added in v2.0.1
type PlatformSnapshot struct {
Name string
Capabilities capability.Capabilities
}
type RuntimeMigration ¶
type RuntimeSnapshot ¶ added in v2.0.1
type RuntimeSnapshot struct {
Name string
State RuntimeState
StartedAt time.Time
Uptime time.Duration
Platforms []PlatformSnapshot
}
type RuntimeState ¶ added in v2.0.1
type RuntimeState string
const ( StateStarting RuntimeState = "starting" StateRunning RuntimeState = "running" StateStopping RuntimeState = "stopping" StateStopped RuntimeState = "stopped" StateFailed RuntimeState = "failed" )