Skip to main content

subdivide_grace_budget

Function subdivide_grace_budget 

Source
pub fn subdivide_grace_budget(
    grace_remaining: Duration,
    in_flight_count: usize,
    original_budget: Option<Budget>,
) -> Budget
Expand description

Calculate subdivided budget for a request during grace period.

During graceful shutdown, in-flight requests get a proportional share of the remaining grace period.

§Arguments

  • grace_remaining - Time remaining in the grace period
  • in_flight_count - Number of in-flight requests
  • original_budget - The request’s original budget (if any)

§Returns

A budget that is the minimum of:

  • The remaining grace period divided by in-flight count
  • The original budget (if provided)