pub async fn pre_flight_reserve(budget: &PluginBudget) -> f64Expand description
Sleep if the projected budget is too low, then atomically reserve an estimated cost for the upcoming request.
Returns the reserved point amount. Every exit path after this call —
both success and error — must call release_reservation with the returned
value to prevent the pending balance growing indefinitely.
The Mutex guard is released before the .await to satisfy Send bounds.
§Example
use stygian_graph::adapters::graphql_throttle::{
CostThrottleConfig, PluginBudget, pre_flight_reserve, release_reservation,
};
let budget = PluginBudget::new(CostThrottleConfig::default());
let reserved = pre_flight_reserve(&budget).await;
// ... send the request ...
release_reservation(&budget, reserved).await;