livery_disconnect (livery v0.2.0)
View SourceInternal helper for delivering a client-disconnect signal.
Called by the per-stream translator in each adapter when the client
resets the stream or closes the connection. It signals the request
worker two ways: a {livery_disconnect, Ref, Reason} message (for a
handler waiting in a receive loop) and a spawned run of each
registered cancel callback (for a handler blocked in a NIF that would
not see a mailbox message until it returns).
Callbacks are always run in a fresh process via spawn/1, so a slow
or crashing callback cannot block the translator or delay the worker's
'DOWN' cleanup.
Summary
Functions
Signal WorkerPid that the client for Ref disconnected with
Reason, and spawn each registered cancel callback.
Fire on the first disconnect only. Returns the new fired flag
(always true). A no-op when already fired, so a stream reset
followed by a connection close fires once.
Register a cancel callback. If the disconnect already fired, run it immediately (spawned) and leave the list unchanged; otherwise prepend it for the eventual fire.
Functions
Signal WorkerPid that the client for Ref disconnected with
Reason, and spawn each registered cancel callback.
Fire on the first disconnect only. Returns the new fired flag
(always true). A no-op when already fired, so a stream reset
followed by a connection close fires once.
Register a cancel callback. If the disconnect already fired, run it immediately (spawned) and leave the list unchanged; otherwise prepend it for the eventual fire.