{"modulePath":"github.com/txn2/mcp-data-platform","version":"v1.167.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package webhookwire\n\nPackage webhookwire assembles inbound webhooks for the HTTP composition root (#1870): the source store, the receiver mounted at /hooks/, the compactor, and the source service the admin API calls.\n\nEverything a source writes lands in the managed-resources bucket, through a client on the managed-resources S3 connection, because the scratch catalog that reads a source's compacted windows -- which are managed resources -- has to read its raw segments as well. A deployment with no database, no managed resources store or no Trino toolkit has no webhooks.\n\n## Constants\n\n```go\nconst EnvAlertInterval = \"MCP_PLATFORM_WEBHOOK_ALERT_INTERVAL\"\n```\nEnvAlertInterval overrides how often the webhook alerts are evaluated (default a minute), as a Go duration.\n\n## Types\n\n```go\ntype FormCommands interface {\n\tSetForms(f epcmd.FormSources)\n}\n```\nFormCommands is the endpoint kind, whose handler\\_set makes a form's source through what they are handed.\n\n```go\ntype FormDeps struct {\n\tRunner   FormRunner\n\tCommands FormCommands\n\t// Tokens is the run members' issuer, which answers platform.decrypt.\n\tTokens *scripttoken.Issuer\n\t// Audit records each decrypt.\n\tAudit middleware.AuditLogger\n\t// Sealer encrypts and decrypts sensitive fields.\n\tSealer epcollect.Sealer\n\t// Connections names where a source's tables can be created.\n\tConnections func() []string\n\t// MaxFileBytes is resources.managed.max_upload_bytes, the most a form's\n\t// saved file may hold.\n\tMaxFileBytes int64\n}\n```\nFormDeps are what forms are attached through.\n\n```go\ntype FormRunner interface {\n\tSetCollector(c *epcollect.Collector)\n}\n```\nFormRunner is the endpoint runner, which stores a form's accepted submissions through what it is handed.\n\n```go\ntype Webhooks struct {\n\t// Service manages sources; the admin API mounts it.\n\tService *whadmin.Service\n\t// contains filtered or unexported fields\n}\n```\nWebhooks is the assembled feature. A nil \\*Webhooks is a deployment without webhooks, and every method on it does nothing.\n\n```go\nfunc Build(p *platform.Platform, address string, exec whtable.Executor) (*Webhooks, error)\n```\nBuild assembles webhooks from the platform. address is the main listener's, which names this replica. It returns nil when the deployment cannot hold a webhook source, and an error when the receiver's spool is configured and cannot be opened: an operator who asked for acknowledged events to be kept on disk is told at start, not answered without it.\n\n```go\nfunc (w *Webhooks) AttachEventRuns(stored func(ctx context.Context, source string, events []whevent.Event))\n```\nAttachEventRuns has each event this replica stores -- posted, a form's submission, or a message an imap source filed -- told to stored once it is durable (#2332), which enqueues the runs of the automations that name its source. A nil Webhooks attaches nothing.\n\n```go\nfunc (w *Webhooks) AttachForms(d FormDeps)\n```\nAttachForms makes forms store their submissions in webhook sources (#2178): handler\\_set makes each form's source through the source service, and the runner stores each accepted submission through this replica's receiver, sealing sensitive fields first and saving its files as managed resources (#2333); platform.decrypt opens them for a run the form's decrypt\\_personas admit (#2179). A nil Webhooks attaches nothing, and the runner stores no submission, as before.\n\n```go\nfunc (w *Webhooks) AttachScriptRuns(p *platform.Platform)\n```\nAttachScriptRuns enqueues the runs of the automations that name a source for each event this replica stores (#2332), bounded per script by scripts.events.max\\_queued. Which automations name a source is kept in memory and dropped on a NOTIFY from any replica (#2480). A deployment with no database runs no script, and attaches nothing.\n\n```go\nfunc (w *Webhooks) EnableAlerts(sender levelalert.Sender, base string)\n```\nEnableAlerts builds the webhook alert evaluation (#2149), posting through sender and linking to the portal under base. Called before Start; a nil Webhooks does nothing.\n\n```go\nfunc (w *Webhooks) Mount(mux *http.ServeMux)\n```\nMount serves /hooks/ on mux when this replica receives.\n\n```go\nfunc (w *Webhooks) MountAdmin(\n\tmux *http.ServeMux, p *platform.Platform,\n\tauth func(*platform.Platform) func(http.Handler) http.Handler, author func(*http.Request) string,\n)\n```\nMountAdmin registers the webhook source routes behind the admin API's authentication, when there are webhooks and the admin API is enabled.\n\n```go\nfunc (w *Webhooks) Start(ctx context.Context)\n```\nStart begins receiving, compacting, and serving the receiver's own listener when one is configured.\n\n```go\nfunc (w *Webhooks) Stop()\n```\nStop ends the listener, answers every request waiting on a segment, and stops the compactor.\n\n","path":"github.com/txn2/mcp-data-platform/internal/httpserver/webhookwire","name":"webhookwire","synopsis":"Package webhookwire assembles inbound webhooks for the HTTP composition root (#1870): the source store, the receiver mounted at /hooks/, the compactor, and the source service the admin API calls.","isRedistributable":true}
