app

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 96 Imported by: 0

Documentation

Overview

Package app wires configuration, the database, background jobs, the HTTP API and every domain package into one runnable process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CampaignChangeHook

func CampaignChangeHook(a *App) campaigns.ChangeHook

CampaignChangeHook re-checks a campaign's open approval after the composer saved it (the composer's campaigns.Service.AfterChange).

func HeldSendCheck

func HeldSendCheck(a *App) func(ctx context.Context, workspaceID, campaignID uuid.UUID) error

HeldSendCheck is the send-time check the minute job runs for scheduled and held sends: it holds a send that turns Blocked or lost its approval (and tells people), and returns an error wrapping sending.ErrNotReady.

func NewHumaConfig

func NewHumaConfig() huma.Config

NewHumaConfig returns the OpenAPI configuration shared by the server and the `reputecast openapi` command.

func RegisterOperations

func RegisterOperations(h huma.API)

RegisterOperations registers every operation on h without a database, for generating the OpenAPI document. Handlers are never called.

func SecretBox

func SecretBox(cfg *config.Config, log *slog.Logger) (*secrets.Box, error)

SecretBox loads the encryption key (from config or the key file) and returns the box that seals secrets at rest.

func SendRecheck

func SendRecheck(a *App) func(ctx context.Context, campaignID uuid.UUID) (approvals.SendRecheck, error)

SendRecheck is the recheck the sending engine runs as a send starts (its sending.Readiness, via readinessRecheck): Send Readiness again, and the approval must still cover the campaign. It records nothing; the engine holds the send when the verdict is Blocked.

Types

type App

type App struct {
	Cfg     *config.Config
	Log     *slog.Logger
	Pool    *pgxpool.Pool
	Q       *store.Queries
	Secrets *secrets.Box
	Audit   *audit.Logger
	Jobs    *jobs.Client
	JobReg  *jobs.Registry
	Auth    *api.Authenticator
	Metrics *prometheus.Registry
	// Mail sends system mail through the System-stream provider.
	Mail mailer.Sender
	// Sending starts, pauses, resumes and cancels campaign sends; set by the
	// sending domain's start hook.
	Sending sending.Starter
	// Links signs open, click, unsubscribe and preference tokens in emails.
	Links *linktoken.Signer
	// URLs builds public links (tracking, unsubscribe, preferences, archive,
	// shared reports, provider webhooks) on the instance's public URL.
	URLs publicurl.Builder
	// PublicURL is that URL: the saved instance setting, else http.public_url
	// (see wire_publicurl.go).
	PublicURL *publicurl.Source
	// contains filtered or unexported fields
}

App holds the shared dependencies every domain uses.

func New

func New(ctx context.Context, cfg *config.Config, log *slog.Logger) (*App, error)

New connects to the database and builds every dependency. It does not start listeners or workers; see Run.

func (*App) Close

func (a *App) Close()

Close releases the database pool.

func (*App) CommunityRuntime

func (a *App) CommunityRuntime() *remote.Runtime

CommunityRuntime is the App's community adapter runtime (tests that change the configuration stop its sync loop first).

func (*App) Handler

func (a *App) Handler() http.Handler

Handler builds the full HTTP handler for the configured roles.

func (*App) InvalidatePolicy

func (a *App) InvalidatePolicy()

InvalidatePolicy drops the cached authentication policy after a change.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run serves HTTP (web/ingest roles) and runs workers (worker role) until ctx ends.

func (*App) SendingEngine

func (a *App) SendingEngine() *engine.Engine

SendingEngine returns the App's sending engine (the demo command drives it).

Jump to

Keyboard shortcuts

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