linera_core/client/requests_scheduler/scoring.rs
1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/// Configurable weights for the scoring algorithm.
5///
6/// These weights determine the relative importance of different metrics
7/// when calculating a node's performance score. All weights should sum to 1.0.
8///
9/// # Examples
10///
11/// ```ignore
12/// // Prioritize response time and success rate equally
13/// let balanced_weights = ScoringWeights {
14/// latency: 0.4,
15/// success: 0.4,
16/// load: 0.2,
17/// };
18///
19/// // Prioritize low latency above all else
20/// let latency_focused = ScoringWeights {
21/// latency: 0.7,
22/// success: 0.2,
23/// load: 0.1,
24/// };
25/// ```
26#[derive(Debug, Clone, Copy)]
27pub struct ScoringWeights {
28 /// Weight for latency metric (lower latency = higher score)
29 pub latency: f64,
30 /// Weight for success rate metric (higher success = higher score)
31 pub success: f64,
32 /// Weight for load metric (lower load = higher score)
33 pub load: f64,
34}
35
36impl Default for ScoringWeights {
37 fn default() -> Self {
38 Self {
39 latency: 0.4, // 40% weight on response time
40 success: 0.4, // 40% weight on success rate
41 load: 0.2, // 20% weight on current load
42 }
43 }
44}