Skip to main content

Module call_chain

Module call_chain 

Source
Expand description

Call-chain tracking for driver <-> plugin callback cycle detection and deadline propagation.

When a plugin calls back into the driver’s PluginHost service for a capability (see crate::core_capabilities and proposal 007, Driver-plugin callback model), that call may itself be forwarded to another plugin, which could in turn call back again. This module tracks the chain of catalogue entry keys invoked under a single root call (identified by a pact-call-chain-id gRPC metadata value) so a cycle - the same entry key being invoked twice in the same chain - is rejected instead of deadlocking or recursing forever, and enforces an absolute deadline (pact-deadline-ms gRPC metadata) so a callback can never outlive the request that triggered it.

Structs§

CallChainGuard
Holds entry_key’s place on chain_id’s call stack until dropped, at which point it is popped back off. Returned by push_call.

Constants§

CALL_CHAIN_ID_METADATA_KEY
gRPC metadata key carrying the call-chain ID on driver<->plugin callback requests.
DEADLINE_METADATA_KEY
gRPC metadata key carrying the absolute deadline (Unix epoch milliseconds) on driver<->plugin callback requests.
DEFAULT_CALL_CHAIN_TIMEOUT
Budget given to a new call chain started by the driver, and the fallback used when a callback arrives with no deadline metadata (defensive default for a non-conforming plugin).

Functions§

deadline_from
Absolute deadline (Unix epoch milliseconds) timeout from now.
default_deadline_ms
Absolute deadline (Unix epoch milliseconds) DEFAULT_CALL_CHAIN_TIMEOUT from now, for starting a new call chain.
is_expired
True if deadline_ms has already passed.
new_call_chain_id
Generate a new call-chain ID for the root of a driver -> plugin call that may trigger callbacks.
now_ms
Current time as Unix epoch milliseconds.
push_call
Push entry_key onto chain_id’s call stack, detecting cycles.
remaining
Remaining budget until deadline_ms, for use as the timeout of the next hop’s own call. Zero if the deadline has already passed.