Documentation
¶
Index ¶
- Constants
- type Config
- type CredentialKeyConfig
- type ExtOption
- func WithAPIMiddleware(mw ...forge.Middleware) ExtOption
- func WithBasePath(path string) ExtOption
- func WithConfig(cfg Config) ExtOption
- func WithDisableMigrate() ExtOption
- func WithDisableRoutes() ExtOption
- func WithDriver(d driver.Driver) ExtOption
- func WithGroveDatabase(name string) ExtOption
- func WithHeraldOption(opt herald.Option) ExtOption
- func WithRequireConfig(require bool) ExtOption
- func WithStore(s store.Store) ExtOption
- type Extension
- func (e *Extension) API() *api.ForgeAPI
- func (e *Extension) APIProtected() bool
- func (e *Extension) BasePath() string
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) Herald() *herald.Herald
- func (e *Extension) Init(fapp forge.App) error
- func (e *Extension) Register(fapp forge.App) error
- func (e *Extension) RegisterContractContributor(disp *dispatcher.Dispatcher, reg dashcontract.Registry, ...) error
- func (e *Extension) RegisterRoutes(router forge.Router)
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
- type ProviderConfig
Constants ¶
const ExtensionDescription = "Unified multi-channel notification delivery engine"
ExtensionDescription is the human-readable description.
const ExtensionName = "herald"
ExtensionName is the name registered with Forge.
const ExtensionVersion = "1.8.0"
ExtensionVersion is the semantic version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Config embeds the core herald configuration.
herald.Config `json:",inline" yaml:",inline" mapstructure:",squash"`
// BasePath is the URL prefix for all herald routes (default: "/herald").
BasePath string `json:"base_path" yaml:"base_path" mapstructure:"base_path"`
// DisableRoutes disables automatic route registration with the Forge router.
DisableRoutes bool `json:"disable_routes" yaml:"disable_routes" mapstructure:"disable_routes"`
// DisableMigrate disables automatic database migration on Register.
DisableMigrate bool `json:"disable_migrate" yaml:"disable_migrate" mapstructure:"disable_migrate"`
// GroveDatabase is the name of a grove.DB registered in the DI container.
// When set, the extension resolves this named database and auto-constructs
// the appropriate store based on the driver type (pg/sqlite/mongo).
// When empty and WithGroveDatabase was called, the default (unnamed) DB is used.
GroveDatabase string `json:"grove_database" mapstructure:"grove_database" yaml:"grove_database"`
// Providers declares notification providers seeded into the store on
// startup (seed-if-absent). Credentials may use ${ENV} interpolation.
Providers []ProviderConfig `json:"providers" yaml:"providers" mapstructure:"providers"`
// CredentialsKey encrypts provider credentials at rest: 32 bytes,
// standard base64. Without it credentials are stored in plaintext, and
// the dashboard says so. Supports ${ENV} interpolation.
CredentialsKey string `json:"credentials_key" yaml:"credentials_key" mapstructure:"credentials_key"`
// CredentialsKeyID is stored beside every value the key encrypts
// (default "k1"). Change it when you rotate to a new key.
CredentialsKeyID string `json:"credentials_key_id" yaml:"credentials_key_id" mapstructure:"credentials_key_id"`
// PreviousCredentialsKeys only decrypt, so values written under an older
// key keep working after a rotation.
PreviousCredentialsKeys []CredentialKeyConfig `json:"previous_credentials_keys" yaml:"previous_credentials_keys" mapstructure:"previous_credentials_keys"`
// DashboardAppID is the app the dashboard shows to a session that carries
// no app_id claim. Empty means the "" app, where standalone installs keep
// their data. A session whose claim is present but unusable is refused,
// never shown this app.
DashboardAppID string `json:"dashboard_app_id" yaml:"dashboard_app_id" mapstructure:"dashboard_app_id"`
// RequireConfig requires config to be present in YAML files.
// If true and no config is found, Register returns an error.
RequireConfig bool `json:"-" yaml:"-"`
}
Config holds configuration for the Herald Forge extension. Fields can be set programmatically via ExtOption functions or loaded from YAML configuration files (under "extensions.herald" or "herald" keys).
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
func (Config) ToHeraldOptions ¶
ToHeraldOptions converts the embedded Config into herald.Option values.
type CredentialKeyConfig ¶
type CredentialKeyConfig struct {
ID string `json:"id" yaml:"id" mapstructure:"id"`
Key string `json:"key" yaml:"key" mapstructure:"key"`
}
CredentialKeyConfig is one previous credential key.
type ExtOption ¶
type ExtOption func(*Extension)
ExtOption configures the Herald Forge extension.
func WithAPIMiddleware ¶
func WithAPIMiddleware(mw ...forge.Middleware) ExtOption
WithAPIMiddleware runs mw in front of every Herald REST route. Herald can't know your auth scheme, so this is where you put it. Without it, startup warns that the API is unauthenticated. Tenant isolation rests on this middleware too: it must bind each caller to the app_id they may use.
It applies only to routes Herald mounts itself. A host that disables them and mounts the API through Extension.RegisterRoutes gets no middleware from Herald and must apply its own on that router.
func WithBasePath ¶
WithBasePath sets the URL prefix for all herald routes.
func WithConfig ¶
WithConfig sets the extension configuration directly.
func WithDisableMigrate ¶
func WithDisableMigrate() ExtOption
WithDisableMigrate disables automatic database migration on Register.
func WithDisableRoutes ¶
func WithDisableRoutes() ExtOption
WithDisableRoutes disables automatic route registration.
func WithDriver ¶
WithDriver registers a notification driver with the Herald instance.
func WithGroveDatabase ¶
WithGroveDatabase sets the name of the grove.DB to resolve from the DI container. The extension will auto-construct the appropriate store backend (postgres/sqlite/mongo) based on the grove driver type. Pass an empty string to use the default (unnamed) grove.DB.
func WithHeraldOption ¶
WithHeraldOption appends a raw herald.Option to the extension.
func WithRequireConfig ¶
WithRequireConfig requires configuration to be present in YAML files. If true and no config is found, Register returns an error.
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension adapts Herald as a Forge extension. It implements the forge.Extension interface for full Forge lifecycle integration including registration, migration, route mounting, and graceful shutdown.
func (*Extension) APIProtected ¶
APIProtected reports whether the REST API was mounted behind middleware. False also when routes are disabled and the host mounts them itself.
func (*Extension) Health ¶
Health implements forge.Extension.
func (*Extension) Herald ¶
Herald returns the underlying Herald instance. This is nil until Register is called.
func (*Extension) Init ¶
Init initializes the extension. In a Forge environment, this is called during Register. For standalone use, call it manually.
func (*Extension) Register ¶
Register implements forge.Extension. It loads configuration, initializes Herald, runs migrations, registers routes, and provides the Herald instance to the DI container.
func (*Extension) RegisterContractContributor ¶
func (e *Extension) RegisterContractContributor( disp *dispatcher.Dispatcher, reg dashcontract.Registry, wreg dashcontract.WardenRegistry, ) error
RegisterContractContributor implements dashboard.ContractContributorAware. It registers the herald contract contributor, which is what the React shell reads.
func (*Extension) RegisterRoutes ¶
RegisterRoutes registers all Herald API routes into a Forge router. Use this for Forge extension integration where the parent app owns the router. Middleware from WithAPIMiddleware is not applied here: guard router yourself (router.Use, before calling this) or every route is open.
type ProviderConfig ¶
type ProviderConfig struct {
Name string `json:"name" yaml:"name" mapstructure:"name"`
Channel string `json:"channel" yaml:"channel" mapstructure:"channel"`
Driver string `json:"driver" yaml:"driver" mapstructure:"driver"`
AppID string `json:"app_id" yaml:"app_id" mapstructure:"app_id"`
Credentials map[string]string `json:"credentials" yaml:"credentials" mapstructure:"credentials"`
Settings map[string]string `json:"settings" yaml:"settings" mapstructure:"settings"`
Priority int `json:"priority" yaml:"priority" mapstructure:"priority"`
Enabled *bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
}
ProviderConfig declares a notification provider in config.yaml. It is seeded into the store on startup (see SeedConfiguredProviders).