44//! - group these enablers into more logical categories
55//! - redefine the actual categories so those miscellaneous enablers fit into them
66
7- use anyhow:: { Context , anyhow} ;
8- use reqwest:: Url ;
7+ use anyhow:: anyhow;
98use std:: sync:: Arc ;
109use std:: time:: Duration ;
1110
11+ use mithril_aggregator_client:: AggregatorHttpClient ;
12+ use mithril_common:: logging:: LoggerExtensions ;
1213#[ cfg( feature = "future_dmq" ) ]
1314use mithril_common:: messages:: RegisterSignatureMessageDmq ;
1415#[ cfg( feature = "future_dmq" ) ]
@@ -21,9 +22,10 @@ use crate::get_dependency;
2122#[ cfg( feature = "future_dmq" ) ]
2223use crate :: services:: SignatureConsumerDmq ;
2324use crate :: services:: {
24- AggregatorHTTPClient , MessageService , MithrilMessageService , SequentialSignatureProcessor ,
25- SignatureConsumer , SignatureConsumerNoop , SignatureProcessor ,
25+ MessageService , MithrilMessageService , SequentialSignatureProcessor , SignatureConsumer ,
26+ SignatureConsumerNoop , SignatureProcessor ,
2627} ;
28+
2729impl DependenciesBuilder {
2830 async fn build_signed_entity_type_lock ( & mut self ) -> Result < Arc < SignedEntityTypeLock > > {
2931 let signed_entity_lock = Arc :: new ( SignedEntityTypeLock :: default ( ) ) ;
@@ -60,29 +62,23 @@ impl DependenciesBuilder {
6062 get_dependency ! ( self . message_service)
6163 }
6264
63- /// Builds an [AggregatorHTTPClient ]
64- pub async fn build_leader_aggregator_client ( & mut self ) -> Result < Arc < AggregatorHTTPClient > > {
65+ /// Builds an [AggregatorHttpClient ]
66+ pub async fn build_leader_aggregator_client ( & mut self ) -> Result < Arc < AggregatorHttpClient > > {
6567 let leader_aggregator_endpoint = self . configuration . leader_aggregator_endpoint ( ) . ok_or (
6668 anyhow ! ( "Leader Aggregator endpoint is mandatory for follower Aggregator" ) ,
6769 ) ?;
6870
69- let aggregator_client = AggregatorHTTPClient :: new (
70- Url :: parse ( & leader_aggregator_endpoint) . with_context ( || {
71- format ! (
72- "Failed to parse leader aggregator endpoint: '{leader_aggregator_endpoint}'"
73- )
74- } ) ?,
75- None ,
76- self . get_api_version_provider ( ) . await ?,
77- Some ( Duration :: from_secs ( 30 ) ) ,
78- self . root_logger ( ) ,
79- ) ;
71+ let aggregator_client = AggregatorHttpClient :: builder ( & leader_aggregator_endpoint)
72+ . with_api_version_provider ( self . get_api_version_provider ( ) . await ?)
73+ . with_timeout ( Duration :: from_secs ( 30 ) )
74+ . with_logger ( self . root_logger . new_with_name ( "LeaderAggregatorClient" ) )
75+ . build ( ) ?;
8076
8177 Ok ( Arc :: new ( aggregator_client) )
8278 }
8379
84- /// Returns a leader [AggregatorHTTPClient ]
85- pub async fn get_leader_aggregator_client ( & mut self ) -> Result < Arc < AggregatorHTTPClient > > {
80+ /// Returns a leader [AggregatorHttpClient ]
81+ pub async fn get_leader_aggregator_client ( & mut self ) -> Result < Arc < AggregatorHttpClient > > {
8682 get_dependency ! ( self . leader_aggregator_client)
8783 }
8884
0 commit comments