@@ -11,13 +11,12 @@ use anyhow::{anyhow, Context};
1111use futures:: stream:: FuturesUnordered ;
1212use futures:: StreamExt ;
1313use hyper:: header:: CONTENT_TYPE ;
14- use libdd_common:: HttpClient ;
1514use libdd_common:: {
1615 header:: {
1716 APPLICATION_MSGPACK_STR , APPLICATION_PROTOBUF_STR , DATADOG_SEND_REAL_HTTP_STATUS_STR ,
1817 DATADOG_TRACE_COUNT_STR ,
1918 } ,
20- Endpoint ,
19+ Connect , Endpoint , GenericHttpClient ,
2120} ;
2221use libdd_trace_protobuf:: pb:: { AgentPayload , TracerPayload } ;
2322use send_data_result:: SendDataResult ;
@@ -237,24 +236,27 @@ impl SendData {
237236 /// # Returns
238237 ///
239238 /// A `SendDataResult` instance containing the result of the operation.
240- pub async fn send ( & self , http_client : & HttpClient ) -> SendDataResult {
239+ pub async fn send < C : Connect > ( & self , http_client : & GenericHttpClient < C > ) -> SendDataResult {
241240 self . send_internal ( http_client) . await
242241 }
243242
244- async fn send_internal ( & self , http_client : & HttpClient ) -> SendDataResult {
243+ async fn send_internal < C : Connect > (
244+ & self ,
245+ http_client : & GenericHttpClient < C > ,
246+ ) -> SendDataResult {
245247 if self . use_protobuf ( ) {
246248 self . send_with_protobuf ( http_client) . await
247249 } else {
248250 self . send_with_msgpack ( http_client) . await
249251 }
250252 }
251253
252- async fn send_payload (
254+ async fn send_payload < C : Connect > (
253255 & self ,
254256 chunks : u64 ,
255257 payload : Vec < u8 > ,
256258 headers : HashMap < & ' static str , String > ,
257- http_client : & HttpClient ,
259+ http_client : & GenericHttpClient < C > ,
258260 ) -> ( SendWithRetryResult , u64 , u64 ) {
259261 #[ allow( clippy:: unwrap_used) ]
260262 let payload_len = u64:: try_from ( payload. len ( ) ) . unwrap ( ) ;
@@ -298,7 +300,10 @@ impl SendData {
298300 }
299301 }
300302
301- async fn send_with_protobuf ( & self , http_client : & HttpClient ) -> SendDataResult {
303+ async fn send_with_protobuf < C : Connect > (
304+ & self ,
305+ http_client : & GenericHttpClient < C > ,
306+ ) -> SendDataResult {
302307 let mut result = SendDataResult :: default ( ) ;
303308
304309 #[ allow( clippy:: unwrap_used) ]
@@ -336,7 +341,10 @@ impl SendData {
336341 }
337342 }
338343
339- async fn send_with_msgpack ( & self , http_client : & HttpClient ) -> SendDataResult {
344+ async fn send_with_msgpack < C : Connect > (
345+ & self ,
346+ http_client : & GenericHttpClient < C > ,
347+ ) -> SendDataResult {
340348 let mut result = SendDataResult :: default ( ) ;
341349 let mut futures = FuturesUnordered :: new ( ) ;
342350
0 commit comments