app

package
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app wires platforms, routing, middleware, plugins and storage into a runtime.

Index

Constants

This section is empty.

Variables

View Source
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 New

func New(name string) *App

New creates an application with an empty router and plugin registry.

func (*App) AppMigrations

func (a *App) AppMigrations(m ...plugin.Migration)

func (*App) AutoPluginMigrationsFromStorage

func (a *App) AutoPluginMigrationsFromStorage()

func (*App) AutoPluginSettingsFromStorage

func (a *App) AutoPluginSettingsFromStorage()

func (*App) Cache

func (a *App) Cache(c cache.Cache)

Cache configures the application cache.

func (*App) CacheStore

func (a *App) CacheStore() cache.Cache

CacheStore returns the configured cache.

func (*App) Callback

func (a *App) Callback(pattern string, h middleware.Handler)

func (*App) Command

func (a *App) Command(name string, h middleware.Handler)

func (*App) CommandPrefixes

func (a *App) CommandPrefixes(prefixes ...string)

CommandPrefixes sets the accepted text command prefixes. The default is "/".

func (*App) CoreMigrations

func (a *App) CoreMigrations(m ...plugin.Migration)

func (*App) Dispatch

func (a *App) Dispatch(ctx context.Context, ev event.Event) (err error)

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

func (a *App) FSM(manager *fsm.Manager) *fsm.Manager

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) Match

func (a *App) Match(re *regexp.Regexp, h middleware.Handler)

func (*App) Message

func (a *App) Message(h middleware.Handler)

func (*App) MigrateDown

func (a *App) MigrateDown(ctx context.Context, steps int) (int, error)

func (*App) MigrateUp

func (a *App) MigrateUp(ctx context.Context) (MigrationReport, error)

func (*App) MigrationPlan

func (a *App) MigrationPlan() []RuntimeMigration

func (*App) MigrationStatus

func (a *App) MigrationStatus(ctx context.Context) ([]MigrationStatus, error)

func (*App) On

func (a *App) On(t event.Type, h middleware.Handler)

func (*App) Platform

func (a *App) Platform(p platform.Platform)

Platform registers an adapter by its name and injects the application logger.

func (*App) Plugin

func (a *App) Plugin(p plugin.Plugin) error

Plugin registers a compile-time plugin.

func (*App) PluginMigrations

func (a *App) PluginMigrations(store plugin.MigrationStateStore)

func (*App) PluginSettings

func (a *App) PluginSettings(store plugin.SettingsStateStore)

func (*App) Plugins

func (a *App) Plugins() *plugin.Registry

Plugins returns the application plugin registry.

func (*App) RateLimit

func (a *App) RateLimit(rule ratelimit.Rule)

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

func (a *App) SetLogger(logger *slog.Logger)

SetLogger configures structured logging and propagates it to registered adapters.

func (*App) Start

func (a *App) Start(ctx context.Context) (err error)

Start initializes plugins and runs all platforms until ctx is canceled.

func (*App) Storage

func (a *App) Storage(store storage.Store)

Storage configures the standard persistent store.

func (*App) Store

func (a *App) Store() storage.Store

Store returns the configured persistent store.

func (*App) Text

func (a *App) Text(text string, h middleware.Handler)

func (*App) Use

func (a *App) Use(m middleware.Middleware)

Use appends global middleware.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group registers routes with an additional shared middleware chain.

func (*Group) Callback

func (g *Group) Callback(pattern string, h middleware.Handler)

func (*Group) Command

func (g *Group) Command(name string, h middleware.Handler)

func (*Group) Fallback

func (g *Group) Fallback(h middleware.Handler)

func (*Group) Match

func (g *Group) Match(re *regexp.Regexp, h middleware.Handler)

func (*Group) Message

func (g *Group) Message(h middleware.Handler)

func (*Group) On

func (g *Group) On(t event.Type, h middleware.Handler)

func (*Group) Text

func (g *Group) Text(text string, h middleware.Handler)

func (*Group) Use

func (g *Group) Use(m middleware.Middleware)

type MigrationReport

type MigrationReport struct {
	Applied int
	Skipped int
}

type MigrationStatus

type MigrationStatus struct {
	Namespace string
	ID        string
	Name      string
	Applied   bool
	AppliedAt *time.Time
}

type PlatformSnapshot added in v2.0.1

type PlatformSnapshot struct {
	Name         string
	Capabilities capability.Capabilities
}

type RuntimeMigration

type RuntimeMigration struct {
	Namespace string
	Migration plugin.Migration
}

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL