Skip to main content

grate_limiter/
decision.rs

1use serde::{Deserialize, Serialize};
2
3/// The result of a provider selection decision.
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Decision {
6    /// Selected provider name.
7    pub provider: String,
8    /// Composite score [0.0, 1.0].
9    pub score: f32,
10    /// Detailed score breakdown for debugging/observability.
11    pub reasoning: ScoreBreakdown,
12    /// Alternative providers ranked by score (excluding the selected one).
13    pub alternatives: Vec<Alternative>,
14}
15
16/// Detailed breakdown of how a provider was scored.
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct ScoreBreakdown {
19    /// Quota sub-score (remaining capacity + anticipatory penalty).
20    pub quota_score: f32,
21    /// Health sub-score.
22    pub health_score: f32,
23    /// Priority sub-score.
24    pub priority_score: f32,
25    /// Latency sub-score.
26    pub latency_score: f32,
27}
28
29/// An alternative provider candidate with its score.
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct Alternative {
32    /// Provider name.
33    pub provider: String,
34    /// Composite score.
35    pub score: f32,
36}