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§
- Call
Chain Guard - Holds
entry_key’s place onchain_id’s call stack until dropped, at which point it is popped back off. Returned bypush_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)
timeoutfrom now. - default_
deadline_ ms - Absolute deadline (Unix epoch milliseconds)
DEFAULT_CALL_CHAIN_TIMEOUTfrom now, for starting a new call chain. - is_
expired - True if
deadline_mshas 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_keyontochain_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.