9999 inner. clone ( ) ,
100100 id,
101101 shared. metrics . clone ( ) ,
102- & shared. proxy_name ,
102+ shared. proxy_name ,
103103 config. backend_url ( ) ,
104104 connections_limit,
105105 config. backend_timeout ( ) ,
@@ -114,7 +114,7 @@ where
114114 shared. inner ( ) ,
115115 id,
116116 shared. metrics . clone ( ) ,
117- & shared. proxy_name ,
117+ shared. proxy_name ,
118118 peer_url. to_owned ( ) ,
119119 config. backend_max_concurrent_requests ( ) ,
120120 config. backend_timeout ( ) ,
@@ -128,7 +128,7 @@ where
128128 worker_id : id,
129129 inner : inner. clone ( ) ,
130130 metrics : shared. metrics . clone ( ) ,
131- proxy_name : shared. proxy_name . clone ( ) ,
131+ proxy_name : shared. proxy_name ,
132132 mirroring_peers : peers. clone ( ) ,
133133 mirroring_peer_round_robin_index : AtomicUsize :: new ( 0 ) ,
134134 }
@@ -141,7 +141,7 @@ where
141141 config : C ,
142142 tls : ConfigTls ,
143143 metrics : Arc < Metrics > ,
144- proxy_name : & str ,
144+ proxy_name : & ' static str ,
145145 canceller : tokio_util:: sync:: CancellationToken ,
146146 resetter : broadcast:: Sender < ( ) > ,
147147 ) -> Result < ( ) , Box < dyn std:: error:: Error + Send > > {
@@ -195,11 +195,7 @@ where
195195 . wrap ( NormalizePath :: new ( TrailingSlash :: Trim ) )
196196 . default_service ( web:: route ( ) . to ( Self :: receive) )
197197 } )
198- . on_connect ( Self :: on_connect (
199- metrics. clone ( ) ,
200- client_connections_count,
201- proxy_name. to_string ( ) ,
202- ) )
198+ . on_connect ( Self :: on_connect ( metrics. clone ( ) , client_connections_count, proxy_name) )
203199 . shutdown_signal ( canceller. cancelled_owned ( ) )
204200 . workers ( workers_count) ;
205201
@@ -315,7 +311,7 @@ where
315311 . metrics
316312 . client_info
317313 . get_or_create ( & LabelsProxyClientInfo {
318- proxy : this. shared . proxy_name . clone ( ) ,
314+ proxy : this. shared . proxy_name ,
319315 user_agent : user_agent. to_string ( ) ,
320316 } )
321317 . inc ( ) ;
@@ -344,7 +340,7 @@ where
344340 this. shared
345341 . metrics
346342 . http_proxy_failure_count
347- . get_or_create ( & LabelsProxy { proxy : this. shared . proxy_name . clone ( ) } )
343+ . get_or_create ( & LabelsProxy { proxy : this. shared . proxy_name } )
348344 . inc ( ) ;
349345 return Ok ( HttpResponse :: BadGateway ( ) . body ( format ! ( "Backend error: {:?}" , err) ) ) ;
350346 }
@@ -407,7 +403,7 @@ where
407403 inner : Arc < P > ,
408404 worker_id : Uuid ,
409405 metrics : Arc < Metrics > ,
410- proxy_name : & str ,
406+ proxy_name : & ' static str ,
411407 mirroring_peers : Arc < Vec < actix:: Addr < ProxyHttpBackendEndpoint < C , P > > > > ,
412408 mut mirroring_peer_round_robin_index : usize ,
413409 ) {
@@ -478,7 +474,7 @@ where
478474 mut mrr_res : ProxiedHttpResponse ,
479475 inner : Arc < P > ,
480476 metrics : Arc < Metrics > ,
481- proxy_name : & str ,
477+ proxy_name : & ' static str ,
482478 worker_id : Uuid ,
483479 ) {
484480 if cli_req. decompressed_size < cli_req. size {
@@ -496,7 +492,7 @@ where
496492 metrics
497493 . http_mirror_success_count
498494 . get_or_create ( & LabelsProxyHttpJrpc {
499- proxy : proxy_name. to_string ( ) ,
495+ proxy : proxy_name,
500496 jrpc_method : cli_req. info . jrpc_method_enriched ,
501497 } )
502498 . inc ( ) ;
@@ -740,18 +736,16 @@ where
740736 req : & ProxiedHttpRequest ,
741737 res : & ProxiedHttpResponse ,
742738 metrics : Arc < Metrics > ,
743- proxy_name : & str ,
739+ proxy_name : & ' static str ,
744740 ) {
745741 let metric_labels_jrpc = match jrpc {
746- JrpcRequestMetaMaybeBatch :: Single ( jrpc) => LabelsProxyHttpJrpc {
747- jrpc_method : jrpc. method_enriched ( ) ,
748- proxy : proxy_name. to_string ( ) ,
749- } ,
742+ JrpcRequestMetaMaybeBatch :: Single ( jrpc) => {
743+ LabelsProxyHttpJrpc { jrpc_method : jrpc. method_enriched ( ) , proxy : proxy_name }
744+ }
750745
751- JrpcRequestMetaMaybeBatch :: Batch ( _) => LabelsProxyHttpJrpc {
752- jrpc_method : Cow :: Borrowed ( "batch" ) ,
753- proxy : proxy_name. to_string ( ) ,
754- } ,
746+ JrpcRequestMetaMaybeBatch :: Batch ( _) => {
747+ LabelsProxyHttpJrpc { jrpc_method : Cow :: Borrowed ( "batch" ) , proxy : proxy_name }
748+ }
755749 } ;
756750
757751 let latency_backend = 1000000.0 * ( res. start ( ) - req. end ( ) ) . as_seconds_f64 ( ) ;
@@ -785,7 +779,7 @@ where
785779 for jrpc in batch. iter ( ) {
786780 let metric_labels_jrpc = LabelsProxyHttpJrpc {
787781 jrpc_method : jrpc. method_enriched ( ) ,
788- proxy : proxy_name. to_string ( ) ,
782+ proxy : proxy_name,
789783 } ;
790784 metrics. http_proxy_success_count . get_or_create ( & metric_labels_jrpc) . inc ( ) ;
791785 }
@@ -843,7 +837,7 @@ where
843837{
844838 inner : Arc < P > ,
845839 metrics : Arc < Metrics > ,
846- proxy_name : String ,
840+ proxy_name : & ' static str ,
847841
848842 client_connections_count : Arc < AtomicI64 > ,
849843
@@ -855,11 +849,11 @@ where
855849 C : ConfigProxyHttp ,
856850 P : ProxyHttpInner < C > ,
857851{
858- fn new ( config : C , metrics : & Arc < Metrics > , proxy_name : & str ) -> Self {
852+ fn new ( config : C , metrics : & Arc < Metrics > , proxy_name : & ' static str ) -> Self {
859853 Self {
860854 inner : Arc :: new ( P :: new ( config) ) ,
861855 metrics : metrics. clone ( ) ,
862- proxy_name : proxy_name . to_string ( ) ,
856+ proxy_name,
863857 client_connections_count : Arc :: new ( AtomicI64 :: new ( 0 ) ) ,
864858 _config : PhantomData ,
865859 }
@@ -886,7 +880,7 @@ where
886880 inner : Arc < P > ,
887881 worker_id : Uuid ,
888882 metrics : Arc < Metrics > ,
889- proxy_name : String ,
883+ proxy_name : & ' static str ,
890884
891885 /// mirroring_peers is the vector of endpoints for mirroring peers.
892886 mirroring_peers : Arc < Vec < actix:: Addr < ProxyHttpBackendEndpoint < C , P > > > > ,
@@ -919,7 +913,7 @@ where
919913 fn handle ( & mut self , msg : ProxiedHttpCombo , ctx : & mut Self :: Context ) -> Self :: Result {
920914 let inner = self . inner . clone ( ) ;
921915 let metrics = self . metrics . clone ( ) ;
922- let proxy_name = self . proxy_name . clone ( ) ;
916+ let proxy_name = self . proxy_name ;
923917 let worker_id = self . worker_id ;
924918 let mirroring_peers = self . mirroring_peers . clone ( ) ;
925919 let mut mirroring_peer_round_robin_index =
@@ -933,7 +927,7 @@ where
933927 inner,
934928 worker_id,
935929 metrics,
936- & proxy_name,
930+ proxy_name,
937931 mirroring_peers,
938932 mirroring_peer_round_robin_index,
939933 ) ;
@@ -960,7 +954,7 @@ where
960954 inner : Arc < P > ,
961955 worker_id : Uuid ,
962956 metrics : Arc < Metrics > ,
963- proxy_name : String ,
957+ proxy_name : & ' static str ,
964958
965959 client : Client ,
966960 url : Url ,
@@ -977,7 +971,7 @@ where
977971 inner : Arc < P > ,
978972 worker_id : Uuid ,
979973 metrics : Arc < Metrics > ,
980- proxy_name : & str ,
974+ proxy_name : & ' static str ,
981975 url : Url ,
982976 connections_limit : usize ,
983977 timeout : std:: time:: Duration ,
@@ -993,15 +987,7 @@ where
993987 . timeout ( timeout)
994988 . finish ( ) ;
995989
996- Self {
997- inner,
998- worker_id,
999- metrics,
1000- proxy_name : proxy_name. to_string ( ) ,
1001- client,
1002- url,
1003- _config : PhantomData ,
1004- }
990+ Self { inner, worker_id, metrics, proxy_name, client, url, _config : PhantomData }
1005991 }
1006992
1007993 fn new_backend_request ( & self , info : & ProxyHttpRequestInfo ) -> ClientRequest {
@@ -1043,7 +1029,7 @@ where
10431029 let inner = self . inner . clone ( ) ;
10441030 let worker_id = self . worker_id ;
10451031 let metrics = self . metrics . clone ( ) ;
1046- let proxy_name = self . proxy_name . clone ( ) ;
1032+ let proxy_name = self . proxy_name ;
10471033
10481034 let mrr_req = self . new_backend_request ( & cli_req. info ) ;
10491035 let mrr_req_body = cli_req. body . clone ( ) ;
@@ -1076,12 +1062,7 @@ where
10761062 end,
10771063 } ;
10781064 ProxyHttp :: < C , P > :: postprocess_mirrored_response (
1079- cli_req,
1080- mrr_res,
1081- inner,
1082- metrics,
1083- & proxy_name,
1084- worker_id,
1065+ cli_req, mrr_res, inner, metrics, proxy_name, worker_id,
10851066 ) ;
10861067 }
10871068 Err ( err) => {
@@ -1094,7 +1075,7 @@ where
10941075 ) ;
10951076 metrics
10961077 . http_mirror_failure_count
1097- . get_or_create ( & LabelsProxy { proxy : proxy_name. clone ( ) } )
1078+ . get_or_create ( & LabelsProxy { proxy : proxy_name } )
10981079 . inc ( ) ;
10991080 }
11001081 } ;
@@ -1110,7 +1091,7 @@ where
11101091 ) ;
11111092 metrics
11121093 . http_mirror_failure_count
1113- . get_or_create ( & LabelsProxy { proxy : proxy_name. clone ( ) } )
1094+ . get_or_create ( & LabelsProxy { proxy : proxy_name } )
11141095 . inc ( ) ;
11151096 }
11161097 }
0 commit comments