@@ -508,7 +508,7 @@ impl ChainSection {
508
508
headers : Default :: default ( ) ,
509
509
rules : vec ! [ ] ,
510
510
} ) ,
511
- weight : 1 ,
511
+ weight : 1.0 ,
512
512
} ;
513
513
let entry = chains. entry ( name. to_string ( ) ) . or_insert_with ( || Chain {
514
514
shard : PRIMARY_SHARD . to_string ( ) ,
@@ -608,8 +608,8 @@ fn btree_map_to_http_headers(kvs: BTreeMap<String, String>) -> HeaderMap {
608
608
pub struct Provider {
609
609
pub label : String ,
610
610
pub details : ProviderDetails ,
611
- #[ serde( default = "one " ) ]
612
- pub weight : usize ,
611
+ #[ serde( default = "one_f64 " ) ]
612
+ pub weight : f64 ,
613
613
}
614
614
615
615
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
@@ -734,8 +734,8 @@ const DEFAULT_PROVIDER_FEATURES: [&str; 2] = ["traces", "archive"];
734
734
impl Provider {
735
735
fn validate ( & mut self ) -> Result < ( ) > {
736
736
validate_name ( & self . label ) . context ( "illegal provider name" ) ?;
737
- if self . weight == 0 {
738
- bail ! ( "provider {} must have a weight greater than 0 " , self . label) ;
737
+ if self . weight < 0.0 || self . weight > 1. 0 {
738
+ bail ! ( "provider {} must have a weight between 0 and 1 " , self . label) ;
739
739
}
740
740
741
741
match self . details {
@@ -925,7 +925,7 @@ impl<'de> Deserialize<'de> for Provider {
925
925
Ok ( Provider {
926
926
label,
927
927
details,
928
- weight : weight. unwrap_or ( 1 ) ,
928
+ weight : weight. unwrap_or ( 1.0 ) ,
929
929
} )
930
930
}
931
931
}
@@ -1186,6 +1186,10 @@ fn one() -> usize {
1186
1186
1
1187
1187
}
1188
1188
1189
+ fn one_f64 ( ) -> f64 {
1190
+ 1.0
1191
+ }
1192
+
1189
1193
fn default_node_id ( ) -> NodeId {
1190
1194
NodeId :: new ( "default" ) . unwrap ( )
1191
1195
}
@@ -1332,7 +1336,7 @@ mod tests {
1332
1336
headers: HeaderMap :: new( ) ,
1333
1337
rules: Vec :: new( ) ,
1334
1338
} ) ,
1335
- weight: 1 ,
1339
+ weight: 1.0 ,
1336
1340
} ,
1337
1341
actual
1338
1342
) ;
@@ -1359,7 +1363,7 @@ mod tests {
1359
1363
headers: HeaderMap :: new( ) ,
1360
1364
rules: Vec :: new( ) ,
1361
1365
} ) ,
1362
- weight: 1 ,
1366
+ weight: 1.0 ,
1363
1367
} ,
1364
1368
actual
1365
1369
) ;
@@ -1467,7 +1471,7 @@ mod tests {
1467
1471
headers,
1468
1472
rules: Vec :: new( ) ,
1469
1473
} ) ,
1470
- weight: 1 ,
1474
+ weight: 1.0 ,
1471
1475
} ,
1472
1476
actual
1473
1477
) ;
@@ -1493,7 +1497,7 @@ mod tests {
1493
1497
headers: HeaderMap :: new( ) ,
1494
1498
rules: Vec :: new( ) ,
1495
1499
} ) ,
1496
- weight: 1 ,
1500
+ weight: 1.0 ,
1497
1501
} ,
1498
1502
actual
1499
1503
) ;
@@ -1535,7 +1539,7 @@ mod tests {
1535
1539
conn_pool_size: 20 ,
1536
1540
rules: vec![ ] ,
1537
1541
} ) ,
1538
- weight: 1 ,
1542
+ weight: 1.0 ,
1539
1543
} ,
1540
1544
actual
1541
1545
) ;
@@ -1562,7 +1566,7 @@ mod tests {
1562
1566
conn_pool_size: 20 ,
1563
1567
rules: vec![ ] ,
1564
1568
} ) ,
1565
- weight: 1 ,
1569
+ weight: 1.0 ,
1566
1570
} ,
1567
1571
actual
1568
1572
) ;
@@ -1589,7 +1593,7 @@ mod tests {
1589
1593
conn_pool_size: 20 ,
1590
1594
rules: vec![ ] ,
1591
1595
} ) ,
1592
- weight: 1 ,
1596
+ weight: 1.0 ,
1593
1597
} ,
1594
1598
actual
1595
1599
) ;
@@ -1616,7 +1620,7 @@ mod tests {
1616
1620
conn_pool_size: 20 ,
1617
1621
rules: vec![ ] ,
1618
1622
} ) ,
1619
- weight: 1 ,
1623
+ weight: 1.0 ,
1620
1624
} ,
1621
1625
actual
1622
1626
) ;
@@ -1656,7 +1660,7 @@ mod tests {
1656
1660
}
1657
1661
] ,
1658
1662
} ) ,
1659
- weight: 1 ,
1663
+ weight: 1.0 ,
1660
1664
} ,
1661
1665
actual
1662
1666
) ;
@@ -1696,7 +1700,7 @@ mod tests {
1696
1700
}
1697
1701
] ,
1698
1702
} ) ,
1699
- weight: 1 ,
1703
+ weight: 1.0 ,
1700
1704
} ,
1701
1705
actual
1702
1706
) ;
@@ -1736,7 +1740,7 @@ mod tests {
1736
1740
}
1737
1741
] ,
1738
1742
} ) ,
1739
- weight: 1 ,
1743
+ weight: 1.0 ,
1740
1744
} ,
1741
1745
actual
1742
1746
) ;
@@ -1776,7 +1780,7 @@ mod tests {
1776
1780
}
1777
1781
] ,
1778
1782
} ) ,
1779
- weight: 1 ,
1783
+ weight: 1.0 ,
1780
1784
} ,
1781
1785
actual
1782
1786
) ;
@@ -1871,7 +1875,7 @@ mod tests {
1871
1875
headers: HeaderMap :: new( ) ,
1872
1876
rules: Vec :: new( ) ,
1873
1877
} ) ,
1874
- weight: 1 ,
1878
+ weight: 1.0 ,
1875
1879
} ,
1876
1880
actual
1877
1881
) ;
0 commit comments