pub async fn announce(
state: &AppState,
resource: &Resource,
event: HookEvent,
request: &HookRequest,
row: &Value,
)Expand description
Publish the topic a resource declares for event, if it declares one.
The row is the message. A subscriber to order.placed gets the order,
exactly as the API would have returned it — so the handler is an ordinary
function over an ordinary object, and can be tested by posting one to it.
Never fails the request. By the time this runs the row is committed and
the caller’s response is decided; turning “the message could not be queued”
into a 500 would tell them their write failed when it did not. It is logged
instead, at error, because a dropped announcement is a real problem — just
not theirs.
Deliberately after the after_* hook rather than before it: a hook may still
replace or reject the response, and announcing a create that the hook then
turned into a 409 would be announcing something that did not happen.