Documentation
¶
Overview ¶
Package hookevent holds SubmitQueue's hook events: the source it reports, the types it publishes, and a constructor per type. Centralizing them keeps the wire contract in one place, so a publisher names an event rather than assembling one.
The events follow a request's public status, the one its summary shows: one when the request is received, and one when it lands, fails or is cancelled. Deriving them from the summary rather than from pipeline transitions keeps every hook in step with what a user sees, including a request whose start failed before the pipeline saved it.
Each status announces one event per change of the request, so a hook that retries one change's failed side effect never repeats the others'. Payloads carry the queue, the request id, and that change's URI. The gateway publishes these events and the orchestrator's hook stage consumes them, and a hook there cannot read the gateway's store, so the payload carries what a hook needs to reach the change. A request's URIs never change, so they cannot go stale on redelivery. See doc/rfc/hook-framework.md.
Known gaps, accepted for now:
- request.received is published inside Land, an RPC. If Land records accepted but the publish fails, no later status announces the receipt.
- A finished status is announced again whenever its log is redelivered or resent, so a failed publish repairs itself; a copy that arrives after the queue forgot the id reaches hooks twice. That follows a failure: an orchestrator repair resend, a late log redelivery, or a retry after some of a stack's events were published, which repeats those on every retry.
- Order holds within a request's partition, but a receipt waiting to retry does not hold back the finish, so a hook can see the finish first.
- The queue drops a repeated event id only until the first copy is consumed and collected, seconds later.
Index ¶
Constants ¶
const Source = "submitqueue"
Source is reported on every hook event SubmitQueue publishes. A consumer serving several domains matches on it to recognize SubmitQueue's events.
Variables ¶
This section is empty.
Functions ¶
func NewRequestFinished ¶
func NewRequestFinished(summary entity.RequestSummary) []*basehook.HookEvent
NewRequestFinished builds the events announcing summary's finished status, one per change, and none for a status that has no event. The ids carry summary.RequestVersion, so a status the summary restates mints the same ids and a later finished status the summary moves to mints new ones.
func NewRequestReceived ¶
func NewRequestReceived(summary entity.RequestSummary) []*basehook.HookEvent
NewRequestReceived builds the events announcing that summary's request was received, one per change. A request is received once, so the ids carry version 0 and every republish for the same request mints the same ids.
Types ¶
type Type ¶
type Type string
Type is the event type a consumer filters on.
const ( // TypeRequestReceived announces that the request named in the payload has // left the internal accepting status and is visible to users. It carries no // verdict: the request has not been validated yet. TypeRequestReceived Type = "request.received" // TypeRequestLanded announces that the request named in the payload landed. TypeRequestLanded Type = "request.landed" // TypeRequestFailed announces that the request named in the payload ended in // error. The request's summary carries the reason. TypeRequestFailed Type = "request.failed" // TypeRequestCancelled announces that the request named in the payload was // cancelled before it landed. TypeRequestCancelled Type = "request.cancelled" )