Documentation
¶
Overview ¶
Package app wires configuration, the database, background jobs, the HTTP API and every domain package into one runnable process.
Index ¶
- Constants
- func ApprovalsTickAt(a *App, now time.Time) error
- func CampaignChangeHook(a *App) campaigns.ChangeHook
- func HeldSendCheck(a *App) func(ctx context.Context, workspaceID, campaignID uuid.UUID) error
- func NewHumaConfig() huma.Config
- func ReadinessQueue(ctx context.Context, a *App) (int, error)
- func RegisterOperations(h huma.API)
- func SecretBox(cfg *config.Config, log *slog.Logger) (*secrets.Box, error)
- func SendRecheck(a *App) func(ctx context.Context, campaignID uuid.UUID) (approvals.SendRecheck, error)
- type App
- func (a *App) Audience() *audience.Service
- func (a *App) Close()
- func (a *App) Commerce() *commerce.Service
- func (a *App) CommunityRuntime() *remote.Runtime
- func (a *App) Digests() *digests.Service
- func (a *App) Earn() *earn.Service
- func (a *App) Gifts() *gifts.Service
- func (a *App) Handler() http.Handler
- func (a *App) InvalidatePolicy()
- func (a *App) Offers() *offers.Service
- func (a *App) Pages() *pages.Service
- func (a *App) PinPublicURL(ctx context.Context) error
- func (a *App) Products() *products.Service
- func (a *App) ProxyDetector() *proxycheck.Detector
- func (a *App) Push() *push.Service
- func (a *App) PushFake() *webpushtest.Service
- func (a *App) Revenue() *revenue.Service
- func (a *App) Run(ctx context.Context) error
- func (a *App) RunSMTPRelay(ctx context.Context) error
- func (a *App) SMTPRelay() *smtprelay.Relay
- func (a *App) Scoring() *scoring.Service
- func (a *App) SendingEngine() *engine.Engine
- func (a *App) Sponsors() *sponsors.Service
- func (a *App) Transactional() *transactional.Service
- func (a *App) TransactionalOutbox() *engine.TransactionalOutbox
- func (a *App) Website() *website.Service
- func (a *App) WhatsApp() *whatsapp.Service
- func (a *App) WhatsAppFake() *metatest.Fake
Constants ¶
const SourceGiftRedeem = "gift_redeem"
SourceGiftRedeem is the consent source of a redeemed gift.
Variables ¶
This section is empty.
Functions ¶
func ApprovalsTickAt ¶
ApprovalsTickAt runs Review & send's minute job as if it were now: tests move the clock to a scheduled send's recheck, or past a held send's expiry.
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 ¶
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 ¶
NewHumaConfig returns the OpenAPI configuration shared by the server and the `reputecast openapi` command.
func ReadinessQueue ¶
ReadinessQueue works the Send Readiness runs waiting in the job queue, in this process: tests (whose app runs no workers) call it after asking for a run. It returns how many it worked.
func RegisterOperations ¶
RegisterOperations registers every operation on h without a database, for generating the OpenAPI document. Handlers are never called.
func SecretBox ¶
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
// Counts keeps the slow audience counts that read every contact for a
// minute (review 2026-11 OP-12); audited contact changes drop a
// workspace's.
Counts *countcache.Cache
// Now is the clock of the services that read it (texting); nil is the
// wall clock. Tests that seed the sample at a fixed moment set it.
Now func() time.Time
// 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 ¶
New connects to the database and builds every dependency. It does not start listeners or workers; see Run.
func (*App) CommunityRuntime ¶
CommunityRuntime is the App's community adapter runtime (tests that change the configuration stop its sync loop first).
func (*App) InvalidatePolicy ¶
func (a *App) InvalidatePolicy()
InvalidatePolicy drops the cached authentication policy after a change.
func (*App) PinPublicURL ¶
PinPublicURL makes the address the server locks (http.public_url_locked) the saved public URL when another one is saved, and moves provider webhooks to it when an admin had saved another address. So turning the lock on, or the operator changing the locked address, takes effect at the next start without anyone saving it in Instance admin. One process wins the update, so webhooks move once; the change is audited as the server configuration's.
func (*App) ProxyDetector ¶
func (a *App) ProxyDetector() *proxycheck.Detector
ProxyDetector returns the App's untrusted proxy detector (tests flush it).
func (*App) PushFake ¶
func (a *App) PushFake() *webpushtest.Service
PushFake is the in-process push service the demo's subscriptions (and tests) are sent to: nothing reaches FCM, Mozilla, Apple or Windows.
func (*App) RunSMTPRelay ¶
RunSMTPRelay runs the SMTP relay's listeners until ctx ends, in processes with the web role (the relay is an API surface, like the HTTP API). It returns once the listeners stopped gracefully.
func (*App) SendingEngine ¶
SendingEngine returns the App's sending engine (the demo command drives it).
func (*App) Transactional ¶
func (a *App) Transactional() *transactional.Service
Transactional is the transactional domain (tests set its clock).
func (*App) TransactionalOutbox ¶
func (a *App) TransactionalOutbox() *engine.TransactionalOutbox
TransactionalOutbox is the sending engine's transactional outbox (tests drive it with Step).
func (*App) WhatsAppFake ¶
WhatsAppFake is the in-process Graph API the demo's account (and tests) answer from: nothing reaches Meta.
Source Files
¶
- app.go
- metrics.go
- reference.go
- register.go
- schema.go
- wire_accessibility.go
- wire_accessrequests.go
- wire_adapters.go
- wire_agency.go
- wire_ai.go
- wire_apikeys.go
- wire_applang.go
- wire_approvals.go
- wire_audience.go
- wire_auditlog.go
- wire_automations.go
- wire_brandkit.go
- wire_campaigns.go
- wire_canary.go
- wire_commerce.go
- wire_connect.go
- wire_counters.go
- wire_customhost.go
- wire_deliverability.go
- wire_digests.go
- wire_earn.go
- wire_earn_catalog.go
- wire_erasure.go
- wire_forms.go
- wire_gifts.go
- wire_grow.go
- wire_grow_sources.go
- wire_growth.go
- wire_imports.go
- wire_instance.go
- wire_integrations.go
- wire_integrations_languages.go
- wire_languages.go
- wire_mailbox.go
- wire_mcpserver.go
- wire_media.go
- wire_notify.go
- wire_offers.go
- wire_overview.go
- wire_pages.go
- wire_placement.go
- wire_polls.go
- wire_products.go
- wire_providers.go
- wire_proxycheck.go
- wire_publicurl.go
- wire_recommendations.go
- wire_referrals.go
- wire_remote.go
- wire_renders.go
- wire_reports.go
- wire_revenue.go
- wire_roles.go
- wire_scoring.go
- wire_search.go
- wire_segments.go
- wire_senders.go
- wire_sending.go
- wire_sessionext.go
- wire_smtprelay.go
- wire_sponsors.go
- wire_systemmail.go
- wire_team.go
- wire_templates.go
- wire_texting.go
- wire_transactional.go
- wire_transactional_approvals.go
- wire_transactional_import.go
- wire_verification.go
- wire_verification_catalog.go
- wire_visibility.go
- wire_webhooks.go
- wire_webpush.go
- wire_website.go
- wire_welcomeprompt.go
- wire_whatsapp.go
- wire_workspaces.go