pub async fn update_budget(budget: &PluginBudget, response_body: &Value)Expand description
Update the PluginBudget from a completed response body.
Extracts extensions.cost.throttleStatus if present and forwards to
LiveBudget::update_from_response.
ยงExample
use serde_json::json;
use stygian_graph::adapters::graphql_throttle::{CostThrottleConfig, PluginBudget, update_budget};
let budget = PluginBudget::new(CostThrottleConfig::default());
let response = json!({
"data": {},
"extensions": { "cost": { "throttleStatus": {
"maximumAvailable": 10000.0,
"currentlyAvailable": 8000.0,
"restoreRate": 500.0,
}}}
});
update_budget(&budget, &response).await;