File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
internal/mithril-aggregator-discovery/src Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1- use std:: collections:: HashMap ;
1+ use std:: { collections:: HashMap , time :: Duration } ;
22
33use anyhow:: Context ;
44use reqwest:: Client ;
@@ -45,6 +45,8 @@ pub struct HttpConfigAggregatorDiscoverer {
4545}
4646
4747impl HttpConfigAggregatorDiscoverer {
48+ const HTTP_TIMEOUT : Duration = Duration :: from_secs ( 10 ) ;
49+
4850 /// Creates a new `HttpConfigAggregatorDiscoverer` instance with the provided results.
4951 pub fn new ( configuration_file_url : & str ) -> Self {
5052 Self {
@@ -54,7 +56,7 @@ impl HttpConfigAggregatorDiscoverer {
5456
5557 /// Builds a reqwest HTTP client.
5658 fn build_client ( & self ) -> StdResult < Client > {
57- let client_builder = Client :: builder ( ) ;
59+ let client_builder = Client :: builder ( ) . timeout ( Self :: HTTP_TIMEOUT ) ;
5860 let client = client_builder. build ( ) ?;
5961
6062 Ok ( client)
Original file line number Diff line number Diff line change 1+ use std:: time:: Duration ;
2+
13use mithril_aggregator_client:: { AggregatorHttpClient , query:: GetAggregatorFeaturesQuery } ;
24use mithril_common:: { StdResult , messages:: AggregatorCapabilities } ;
35
@@ -30,14 +32,18 @@ pub struct AggregatorEndpoint {
3032}
3133
3234impl AggregatorEndpoint {
35+ const HTTP_TIMEOUT : Duration = Duration :: from_secs ( 5 ) ;
36+
3337 /// Create a new AggregatorEndpoint instance
3438 pub fn new ( url : String ) -> Self {
3539 Self { url }
3640 }
3741
3842 /// Retrieve the capabilities of the aggregator
3943 pub async fn retrieve_capabilities ( & self ) -> StdResult < AggregatorCapabilities > {
40- let aggregator_client = AggregatorHttpClient :: builder ( self . url . clone ( ) ) . build ( ) ?;
44+ let aggregator_client = AggregatorHttpClient :: builder ( self . url . clone ( ) )
45+ . with_timeout ( Self :: HTTP_TIMEOUT )
46+ . build ( ) ?;
4147
4248 Ok ( aggregator_client
4349 . send ( GetAggregatorFeaturesQuery :: current ( ) )
You can’t perform that action at this time.
0 commit comments