Opaque, process-safe cancellation token for a logical unary request.
A token starts active and becomes permanently cancelled after cancel/1.
Cancellation is idempotent and may be triggered from any BEAM process.
The token is a one-shot lifecycle signal. It may be intentionally shared by multiple related requests, but once cancelled it can never be reset or reused as an active token. Cancelling it does not roll back a remote side effect and does not prove that an upstream service never received or started processing a request.
Summary
Functions
Wait for cancellation for up to timeout milliseconds.
Permanently cancel a token.
Return whether the token has been cancelled.
Create a new active cancellation token.
Types
Functions
@spec await(t(), timeout()) :: await_result()
Wait for cancellation for up to timeout milliseconds.
Returns :cancelled as soon as cancellation is observed or :timeout when
the supplied timeout expires. Waiting does not consume the token; cancellation
remains terminal and observable by later callers.
@spec cancel(t()) :: :ok
Permanently cancel a token.
The first caller transitions the token and wakes current waiters. Repeated or
concurrent calls are harmless and return :ok.
Return whether the token has been cancelled.
@spec new() :: t()
Create a new active cancellation token.