{"modulePath":"github.com/uber/submitqueue","version":"v0.3.0-20261125210437-add1a4bd2ea2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package hook\n\nPackage hook defines the contract for a hook: a pluggable side effect run in response to a pipeline lifecycle event. Warehouse exports, code-host comments, notifications, and audit trails are all hooks.\n\nWhich hooks run is a property of the event rather than of the deployment: two queues in one host can point at different providers and want different integrations. A host therefore supplies a Hooks resolver, and the controller in platform/hook asks it once per event.\n\nHooks run behind a durable queue, never inline in the pipeline, so a slow or failing integration cannot stall or fail the work that triggered it.\n\n## Types\n\n```go\ntype Hook interface {\n\t// Handle performs the side effect for event.\n\t//\n\t// Delivery is at-least-once, so the same event — identical id — may arrive\n\t// more than once, including after a successful Handle. Implementations must\n\t// be idempotent on the event id.\n\t//\n\t// Returning nil means \"done with this event\", which is also how a hook\n\t// ignores one: there is no filter or subscription API, because a hook that\n\t// does not care about a type simply returns nil, and routing can be added as\n\t// a wiring decorator if it ever pays for itself.\n\t//\n\t// Returning an error retries the event and, past the retry budget,\n\t// dead-letters it. Return plain errors; classification is the consumer's\n\t// job. An error must mean the side effect did not happen — reporting failure\n\t// for work that succeeded turns at-least-once into repeated duplicate\n\t// effects.\n\t//\n\t// A hook must never write pipeline state. Its outcome is invisible to the\n\t// pipeline by design: that is what makes the side effect unable to affect\n\t// the transition that triggered it.\n\t//\n\t// ctx is the delivery's, canceled when the consumer shuts down. Honor it\n\t// and bound the work Handle does: nothing interrupts a Handle that blocks,\n\t// and the delivery waits for it.\n\tHandle(ctx context.Context, event *basehook.HookEvent) error\n\n\t// Name identifies the hook in logs, metrics, and the failure attribution\n\t// the controller reports. Stable and unique among the hooks a host wires.\n\tName() string\n}\n```\nHook performs a side effect in response to a lifecycle event.\n\n```go\ntype Hooks interface {\n\t// For returns the hooks to run for event. They run concurrently, so the\n\t// order of the returned slice does not sequence them: no hook may depend on\n\t// another having already run.\n\t//\n\t// Returning none is an ordinary outcome: it means nothing this host wired\n\t// is interested in the event.\n\t//\n\t// It takes the event rather than a queue name because the envelope carries\n\t// no queue. Which scope selects hooks differs per domain — queue, source,\n\t// event type — and only the host that publishes the payload can read a\n\t// queue out of it, so the choice belongs to the resolver.\n\t//\n\t// Called on every delivery, so resolution must be cheap and must not fail:\n\t// an integration that cannot be reached is a Handle error, not an absent\n\t// hook.\n\tFor(event *basehook.HookEvent) []Hook\n}\n```\nHooks resolves the hooks that run for an event.\n\n","path":"github.com/uber/submitqueue/platform/extension/hook","name":"hook","synopsis":"Package hook defines the contract for a hook: a pluggable side effect run in response to a pipeline lifecycle event.","isRedistributable":true}
