@@ -33,6 +33,7 @@ use crate::stats::Stats;
33
33
use crate :: storage:: object_storage:: ingestor_metadata_path;
34
34
use crate :: storage:: { ObjectStorageError , STREAM_ROOT_DIRECTORY } ;
35
35
use crate :: storage:: { ObjectStoreFormat , PARSEABLE_ROOT_DIRECTORY } ;
36
+ use crate :: HTTP_CLIENT ;
36
37
use actix_web:: http:: header:: { self , HeaderMap } ;
37
38
use actix_web:: { HttpRequest , Responder } ;
38
39
use bytes:: Bytes ;
@@ -76,8 +77,6 @@ pub async fn sync_streams_with_ingestors(
76
77
StreamError :: Anyhow ( err)
77
78
} ) ?;
78
79
79
- let client = reqwest:: Client :: new ( ) ;
80
-
81
80
for ingestor in ingestor_infos {
82
81
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
83
82
warn ! ( "Ingestor {} is not live" , ingestor. domain_name) ;
@@ -89,7 +88,7 @@ pub async fn sync_streams_with_ingestors(
89
88
base_path_without_preceding_slash( ) ,
90
89
stream_name
91
90
) ;
92
- let res = client
91
+ let res = HTTP_CLIENT
93
92
. put ( url)
94
93
. headers ( reqwest_headers. clone ( ) )
95
94
. header ( header:: AUTHORIZATION , & ingestor. token )
@@ -126,7 +125,6 @@ pub async fn sync_users_with_roles_with_ingestors(
126
125
RBACError :: Anyhow ( err)
127
126
} ) ?;
128
127
129
- let client = reqwest:: Client :: new ( ) ;
130
128
let role = to_vec ( & role. clone ( ) ) . map_err ( |err| {
131
129
error ! ( "Fatal: failed to serialize role: {:?}" , err) ;
132
130
RBACError :: SerdeError ( err)
@@ -143,7 +141,7 @@ pub async fn sync_users_with_roles_with_ingestors(
143
141
username
144
142
) ;
145
143
146
- let res = client
144
+ let res = HTTP_CLIENT
147
145
. put ( url)
148
146
. header ( header:: AUTHORIZATION , & ingestor. token )
149
147
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -177,7 +175,6 @@ pub async fn sync_user_deletion_with_ingestors(username: &String) -> Result<(),
177
175
RBACError :: Anyhow ( err)
178
176
} ) ?;
179
177
180
- let client = reqwest:: Client :: new ( ) ;
181
178
for ingestor in ingestor_infos. iter ( ) {
182
179
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
183
180
warn ! ( "Ingestor {} is not live" , ingestor. domain_name) ;
@@ -190,7 +187,7 @@ pub async fn sync_user_deletion_with_ingestors(username: &String) -> Result<(),
190
187
username
191
188
) ;
192
189
193
- let res = client
190
+ let res = HTTP_CLIENT
194
191
. delete ( url)
195
192
. header ( header:: AUTHORIZATION , & ingestor. token )
196
193
. send ( )
@@ -231,7 +228,6 @@ pub async fn sync_user_creation_with_ingestors(
231
228
user. roles . clone_from ( role) ;
232
229
}
233
230
let username = user. username ( ) ;
234
- let client = reqwest:: Client :: new ( ) ;
235
231
236
232
let user = to_vec ( & user) . map_err ( |err| {
237
233
error ! ( "Fatal: failed to serialize user: {:?}" , err) ;
@@ -250,7 +246,7 @@ pub async fn sync_user_creation_with_ingestors(
250
246
username
251
247
) ;
252
248
253
- let res = client
249
+ let res = HTTP_CLIENT
254
250
. post ( url)
255
251
. header ( header:: AUTHORIZATION , & ingestor. token )
256
252
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -283,7 +279,6 @@ pub async fn sync_password_reset_with_ingestors(username: &String) -> Result<(),
283
279
error ! ( "Fatal: failed to get ingestor info: {:?}" , err) ;
284
280
RBACError :: Anyhow ( err)
285
281
} ) ?;
286
- let client = reqwest:: Client :: new ( ) ;
287
282
288
283
for ingestor in ingestor_infos. iter ( ) {
289
284
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
@@ -297,7 +292,7 @@ pub async fn sync_password_reset_with_ingestors(username: &String) -> Result<(),
297
292
username
298
293
) ;
299
294
300
- let res = client
295
+ let res = HTTP_CLIENT
301
296
. post ( url)
302
297
. header ( header:: AUTHORIZATION , & ingestor. token )
303
298
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -338,7 +333,6 @@ pub async fn sync_role_update_with_ingestors(
338
333
RoleError :: SerdeError ( err)
339
334
} ) ?;
340
335
let roles = Bytes :: from ( roles) ;
341
- let client = reqwest:: Client :: new ( ) ;
342
336
343
337
for ingestor in ingestor_infos. iter ( ) {
344
338
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
@@ -352,7 +346,7 @@ pub async fn sync_role_update_with_ingestors(
352
346
name
353
347
) ;
354
348
355
- let res = client
349
+ let res = HTTP_CLIENT
356
350
. put ( url)
357
351
. header ( header:: AUTHORIZATION , & ingestor. token )
358
352
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -401,7 +395,7 @@ pub async fn fetch_daily_stats_from_ingestors(
401
395
StreamError :: Anyhow ( anyhow:: anyhow!( "Invalid URL in Ingestor Metadata: {}" , err) )
402
396
} ) ?;
403
397
404
- let res = reqwest :: Client :: new ( )
398
+ let res = HTTP_CLIENT
405
399
. get ( uri)
406
400
. header ( header:: AUTHORIZATION , & ingestor. token )
407
401
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -512,8 +506,7 @@ pub async fn send_stream_delete_request(
512
506
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
513
507
return Ok ( ( ) ) ;
514
508
}
515
- let client = reqwest:: Client :: new ( ) ;
516
- let resp = client
509
+ let resp = HTTP_CLIENT
517
510
. delete ( url)
518
511
. header ( header:: CONTENT_TYPE , "application/json" )
519
512
. header ( header:: AUTHORIZATION , ingestor. token )
@@ -551,8 +544,7 @@ pub async fn send_retention_cleanup_request(
551
544
if !utils:: check_liveness ( & ingestor. domain_name ) . await {
552
545
return Ok ( first_event_at) ;
553
546
}
554
- let client = reqwest:: Client :: new ( ) ;
555
- let resp = client
547
+ let resp = HTTP_CLIENT
556
548
. post ( url)
557
549
. header ( header:: CONTENT_TYPE , "application/json" )
558
550
. header ( header:: AUTHORIZATION , ingestor. token )
@@ -603,7 +595,7 @@ pub async fn get_cluster_info() -> Result<impl Responder, StreamError> {
603
595
) )
604
596
. expect ( "should always be a valid url" ) ;
605
597
606
- let resp = reqwest :: Client :: new ( )
598
+ let resp = HTTP_CLIENT
607
599
. get ( uri)
608
600
. header ( header:: AUTHORIZATION , ingestor. token . clone ( ) )
609
601
. header ( header:: CONTENT_TYPE , "application/json" )
@@ -752,7 +744,7 @@ async fn fetch_cluster_metrics() -> Result<Vec<Metrics>, PostError> {
752
744
PostError :: Invalid ( anyhow:: anyhow!( "Invalid URL in Ingestor Metadata: {}" , err) )
753
745
} ) ?;
754
746
755
- let res = reqwest :: Client :: new ( )
747
+ let res = HTTP_CLIENT
756
748
. get ( uri)
757
749
. header ( header:: AUTHORIZATION , & ingestor. token )
758
750
. header ( header:: CONTENT_TYPE , "application/json" )
0 commit comments