@@ -274,31 +274,31 @@ where
274274 Ok ( socket. into ( ) )
275275 }
276276
277- fn to_client_response < S > ( bck_res : & ClientResponse < S > ) -> HttpResponseBuilder {
278- let mut cli_res = HttpResponse :: build ( bck_res . status ( ) ) ;
277+ fn to_client_response < S > ( bknd_res : & ClientResponse < S > ) -> HttpResponseBuilder {
278+ let mut clnt_res = HttpResponse :: build ( bknd_res . status ( ) ) ;
279279
280- for ( name , header ) in bck_res . headers ( ) . iter ( ) {
281- if is_hop_by_hop_header ( name ) {
280+ for ( hkey , hval ) in bknd_res . headers ( ) . iter ( ) {
281+ if is_hop_by_hop_header ( hkey ) {
282282 continue ;
283283 }
284- if let Ok ( hname ) = header:: HeaderName :: from_str ( name . as_str ( ) ) {
285- cli_res . append_header ( ( hname , header . clone ( ) ) ) ;
284+ if let Ok ( hkey ) = header:: HeaderName :: from_str ( hkey . as_str ( ) ) {
285+ clnt_res . append_header ( ( hkey , hval . clone ( ) ) ) ;
286286 }
287287 }
288288
289- cli_res
289+ clnt_res
290290 }
291291
292292 /// receive accepts client's (frontend) request and proxies it to
293293 /// backend
294294 async fn receive (
295- cli_req : HttpRequest ,
296- cli_req_body : web:: Payload ,
295+ clnt_req : HttpRequest ,
296+ clnt_req_body : web:: Payload ,
297297 this : web:: Data < Self > ,
298298 ) -> Result < HttpResponse , actix_web:: Error > {
299299 let timestamp = UtcDateTime :: now ( ) ;
300300
301- if let Some ( user_agent) = cli_req . headers ( ) . get ( header:: USER_AGENT ) &&
301+ if let Some ( user_agent) = clnt_req . headers ( ) . get ( header:: USER_AGENT ) &&
302302 !user_agent. is_empty ( ) &&
303303 let Ok ( user_agent) = user_agent. to_str ( )
304304 {
@@ -312,21 +312,21 @@ where
312312 . inc ( ) ;
313313 }
314314
315- let info = ProxyHttpRequestInfo :: new ( & cli_req , cli_req . conn_data :: < ConnectionGuard > ( ) ) ;
315+ let info = ProxyHttpRequestInfo :: new ( & clnt_req , clnt_req . conn_data :: < ConnectionGuard > ( ) ) ;
316316
317317 let id = info. id ;
318318 let connection_id = info. connection_id ;
319319
320- let bck_req = this. backend . new_backend_request ( & info) ;
321- let bck_req_body = ProxyHttpRequestBody :: new (
320+ let bknd_req = this. backend . new_backend_request ( & info) ;
321+ let bknd_req_body = ProxyHttpRequestBody :: new (
322322 this. clone ( ) ,
323323 info,
324- cli_req_body ,
324+ clnt_req_body ,
325325 this. shared . config ( ) . prealloacated_request_buffer_size ( ) ,
326326 timestamp,
327327 ) ;
328328
329- let bck_res = match bck_req . send_stream ( bck_req_body ) . await {
329+ let bknd_res = match bknd_req . send_stream ( bknd_req_body ) . await {
330330 Ok ( res) => res,
331331 Err ( err) => {
332332 warn ! (
@@ -348,21 +348,21 @@ where
348348 } ;
349349
350350 let timestamp = UtcDateTime :: now ( ) ;
351- let status = bck_res . status ( ) ;
352- let mut cli_res = Self :: to_client_response ( & bck_res ) ;
351+ let status = bknd_res . status ( ) ;
352+ let mut clnt_res = Self :: to_client_response ( & bknd_res ) ;
353353
354354 let preallocate = this. shared . config ( ) . prealloacated_response_buffer_size ( ) ;
355- let bck_body = ProxyHttpResponseBody :: new (
355+ let bknd_res_body = ProxyHttpResponseBody :: new (
356356 this,
357357 id,
358358 status,
359- bck_res . headers ( ) . clone ( ) ,
360- bck_res . into_stream ( ) ,
359+ bknd_res . headers ( ) . clone ( ) ,
360+ bknd_res . into_stream ( ) ,
361361 preallocate,
362362 timestamp,
363363 ) ;
364364
365- Ok ( cli_res . streaming ( bck_body ) )
365+ Ok ( clnt_res . streaming ( bknd_res_body ) )
366366 }
367367
368368 fn postprocess_client_request ( & self , req : ProxiedHttpRequest ) {
@@ -380,11 +380,11 @@ where
380380 } ;
381381 }
382382
383- fn postprocess_backend_response ( & self , bck_res : ProxiedHttpResponse ) {
384- let Some ( ( _, cli_req ) ) = self . requests . remove_sync ( & bck_res . info . id ) else {
383+ fn postprocess_backend_response ( & self , bknd_res : ProxiedHttpResponse ) {
384+ let Some ( ( _, clnt_req ) ) = self . requests . remove_sync ( & bknd_res . info . id ) else {
385385 error ! (
386386 proxy = P :: name( ) ,
387- request_id = %bck_res . info. id,
387+ request_id = %bknd_res . info. id,
388388 worker_id = %self . id,
389389 "Proxied http response for unmatching request" ,
390390 ) ;
@@ -393,31 +393,31 @@ where
393393
394394 // hand over to postprocessor asynchronously so that we can return the
395395 // response to the client as early as possible
396- self . postprocessor . do_send ( ProxiedHttpCombo { req : cli_req , res : bck_res } ) ;
396+ self . postprocessor . do_send ( ProxiedHttpCombo { req : clnt_req , res : bknd_res } ) ;
397397 }
398398
399399 fn finalise_proxying (
400- mut cli_req : ProxiedHttpRequest ,
401- mut bck_res : ProxiedHttpResponse ,
400+ mut clnt_req : ProxiedHttpRequest ,
401+ mut bknd_res : ProxiedHttpResponse ,
402402 inner : Arc < P > ,
403403 worker_id : Uuid ,
404404 metrics : Arc < Metrics > ,
405405 mirroring_peers : Arc < Vec < actix:: Addr < ProxyHttpBackendEndpoint < C , P > > > > ,
406406 mut mirroring_peer_round_robin_index : usize ,
407407 ) {
408- if cli_req . decompressed_size < cli_req . size {
409- ( cli_req . decompressed_body , cli_req . decompressed_size ) =
410- decompress ( cli_req . body . clone ( ) , cli_req . size , cli_req . info . content_encoding ( ) ) ;
408+ if clnt_req . decompressed_size < clnt_req . size {
409+ ( clnt_req . decompressed_body , clnt_req . decompressed_size ) =
410+ decompress ( clnt_req . body . clone ( ) , clnt_req . size , clnt_req . info . content_encoding ( ) ) ;
411411 }
412412
413- if bck_res . decompressed_size < bck_res . size {
414- ( bck_res . decompressed_body , bck_res . decompressed_size ) =
415- decompress ( bck_res . body . clone ( ) , bck_res . size , bck_res . info . content_encoding ( ) ) ;
413+ if bknd_res . decompressed_size < bknd_res . size {
414+ ( bknd_res . decompressed_body , bknd_res . decompressed_size ) =
415+ decompress ( bknd_res . body . clone ( ) , bknd_res . size , bknd_res . info . content_encoding ( ) ) ;
416416 }
417417
418- match serde_json:: from_slice :: < JrpcRequestMetaMaybeBatch > ( & cli_req . decompressed_body ) {
418+ match serde_json:: from_slice :: < JrpcRequestMetaMaybeBatch > ( & clnt_req . decompressed_body ) {
419419 Ok ( jrpc) => {
420- if inner. should_mirror ( & jrpc, & cli_req , & bck_res ) {
420+ if inner. should_mirror ( & jrpc, & clnt_req , & bknd_res ) {
421421 let mirrors_count = match inner. config ( ) . mirroring_strategy ( ) {
422422 ConfigProxyHttpMirroringStrategy :: FanOut => mirroring_peers. len ( ) ,
423423 ConfigProxyHttpMirroringStrategy :: RoundRobin => 1 ,
@@ -431,28 +431,28 @@ where
431431 mirroring_peer_round_robin_index = 0 ;
432432 }
433433
434- let mut req = cli_req . clone ( ) ;
434+ let mut req = clnt_req . clone ( ) ;
435435 req. info . jrpc_method_enriched = jrpc. method_enriched ( ) ;
436436 mirroring_peer. do_send ( req. clone ( ) ) ;
437437 }
438438 }
439439
440440 Self :: maybe_log_proxied_request_and_response (
441441 & jrpc,
442- & cli_req ,
443- & bck_res ,
442+ & clnt_req ,
443+ & bknd_res ,
444444 inner. clone ( ) ,
445445 worker_id,
446446 ) ;
447447
448- Self :: emit_metrics_on_proxy_success ( & jrpc, & cli_req , & bck_res , metrics. clone ( ) ) ;
448+ Self :: emit_metrics_on_proxy_success ( & jrpc, & clnt_req , & bknd_res , metrics. clone ( ) ) ;
449449 }
450450
451451 Err ( err) => {
452452 warn ! (
453453 proxy = P :: name( ) ,
454- request_id = %cli_req . info. id,
455- connection_id = %cli_req . info. connection_id,
454+ request_id = %clnt_req . info. id,
455+ connection_id = %clnt_req . info. connection_id,
456456 worker_id = %worker_id,
457457 error = ?err,
458458 "Failed to parse json-rpc request" ,
@@ -462,29 +462,29 @@ where
462462 }
463463
464464 fn postprocess_mirrored_response (
465- mut cli_req : ProxiedHttpRequest ,
466- mut mrr_res : ProxiedHttpResponse ,
465+ mut clnt_req : ProxiedHttpRequest ,
466+ mut mirr_res : ProxiedHttpResponse ,
467467 inner : Arc < P > ,
468468 metrics : Arc < Metrics > ,
469469 worker_id : Uuid ,
470470 ) {
471- if cli_req . decompressed_size < cli_req . size {
472- ( cli_req . decompressed_body , cli_req . decompressed_size ) =
473- decompress ( cli_req . body . clone ( ) , cli_req . size , cli_req . info . content_encoding ( ) ) ;
471+ if clnt_req . decompressed_size < clnt_req . size {
472+ ( clnt_req . decompressed_body , clnt_req . decompressed_size ) =
473+ decompress ( clnt_req . body . clone ( ) , clnt_req . size , clnt_req . info . content_encoding ( ) ) ;
474474 }
475475
476- if mrr_res . decompressed_size < mrr_res . size {
477- ( mrr_res . decompressed_body , mrr_res . decompressed_size ) =
478- decompress ( mrr_res . body . clone ( ) , mrr_res . size , mrr_res . info . content_encoding ( ) ) ;
476+ if mirr_res . decompressed_size < mirr_res . size {
477+ ( mirr_res . decompressed_body , mirr_res . decompressed_size ) =
478+ decompress ( mirr_res . body . clone ( ) , mirr_res . size , mirr_res . info . content_encoding ( ) ) ;
479479 }
480480
481- Self :: maybe_log_mirrored_request ( & cli_req , & mrr_res , worker_id, inner. config ( ) ) ;
481+ Self :: maybe_log_mirrored_request ( & clnt_req , & mirr_res , worker_id, inner. config ( ) ) ;
482482
483483 metrics
484484 . http_mirror_success_count
485485 . get_or_create ( & LabelsProxyHttpJrpc {
486486 proxy : P :: name ( ) ,
487- jrpc_method : cli_req . info . jrpc_method_enriched ,
487+ jrpc_method : clnt_req . info . jrpc_method_enriched ,
488488 } )
489489 . inc ( ) ;
490490 }
@@ -978,51 +978,51 @@ where
978978{
979979 type Result = ( ) ;
980980
981- fn handle ( & mut self , cli_req : ProxiedHttpRequest , ctx : & mut Self :: Context ) -> Self :: Result {
981+ fn handle ( & mut self , clnt_req : ProxiedHttpRequest , ctx : & mut Self :: Context ) -> Self :: Result {
982982 let start = UtcDateTime :: now ( ) ;
983983
984984 let inner = self . inner . clone ( ) ;
985985 let worker_id = self . worker_id ;
986986 let metrics = self . metrics . clone ( ) ;
987987
988- let mrr_req = self . new_backend_request ( & cli_req . info ) ;
989- let mrr_req_body = cli_req . body . clone ( ) ;
988+ let mirr_req = self . new_backend_request ( & clnt_req . info ) ;
989+ let mirr_req_body = clnt_req . body . clone ( ) ;
990990
991991 ctx. spawn (
992992 async move {
993- match mrr_req . send_body ( mrr_req_body ) . await {
994- Ok ( mut bck_res ) => {
993+ match mirr_req . send_body ( mirr_req_body ) . await {
994+ Ok ( mut bknd_res ) => {
995995 let end = UtcDateTime :: now ( ) ;
996996
997- match bck_res . body ( ) . await {
998- Ok ( mrr_res_body ) => {
999- let size = match mrr_res_body . size ( ) {
997+ match bknd_res . body ( ) . await {
998+ Ok ( mirr_res_body ) => {
999+ let size = match mirr_res_body . size ( ) {
10001000 BodySize :: Sized ( size) => size, // Body is always sized
10011001 BodySize :: None | BodySize :: Stream => 0 ,
10021002 } ;
10031003 let info = ProxyHttpResponseInfo :: new (
1004- cli_req . info . id ,
1005- bck_res . status ( ) ,
1006- bck_res . headers ( ) . clone ( ) ,
1004+ clnt_req . info . id ,
1005+ bknd_res . status ( ) ,
1006+ bknd_res . headers ( ) . clone ( ) ,
10071007 ) ;
1008- let mrr_res = ProxiedHttpResponse {
1008+ let mirr_res = ProxiedHttpResponse {
10091009 info,
1010- body : mrr_res_body ,
1010+ body : mirr_res_body ,
10111011 size : size as usize ,
10121012 decompressed_body : Bytes :: new ( ) ,
10131013 decompressed_size : 0 ,
10141014 start,
10151015 end,
10161016 } ;
10171017 ProxyHttp :: < C , P > :: postprocess_mirrored_response (
1018- cli_req , mrr_res , inner, metrics, worker_id,
1018+ clnt_req , mirr_res , inner, metrics, worker_id,
10191019 ) ;
10201020 }
10211021 Err ( err) => {
10221022 warn ! (
10231023 proxy = P :: name( ) ,
1024- request_id = %cli_req . info. id,
1025- connection_id = %cli_req . info. connection_id,
1024+ request_id = %clnt_req . info. id,
1025+ connection_id = %clnt_req . info. connection_id,
10261026 error = ?err,
10271027 "Failed to mirror a request" ,
10281028 ) ;
@@ -1037,8 +1037,8 @@ where
10371037 Err ( err) => {
10381038 warn ! (
10391039 proxy = P :: name( ) ,
1040- request_id = %cli_req . info. id,
1041- connection_id = %cli_req . info. connection_id,
1040+ request_id = %clnt_req . info. id,
1041+ connection_id = %clnt_req . info. connection_id,
10421042 error = ?err,
10431043 "Failed to mirror a request" ,
10441044 ) ;
0 commit comments