@@ -16,8 +16,6 @@ use ahash::AHashMap;
16
16
use bytes:: { Bytes , BytesMut } ;
17
17
use http:: StatusCode ;
18
18
use http:: Uri ;
19
- use pingap_location:: Location ;
20
- use pingap_upstream:: Upstream ;
21
19
use pingap_util:: format_duration;
22
20
use pingora:: cache:: CacheKey ;
23
21
@@ -28,7 +26,7 @@ use opentelemetry::{
28
26
Context ,
29
27
} ;
30
28
use pingora_limits:: inflight:: Guard ;
31
- use std:: { sync :: Arc , time:: Duration } ;
29
+ use std:: time:: Duration ;
32
30
33
31
pub trait ModifyResponseBody : Sync + Send {
34
32
fn handle ( & self , data : Bytes ) -> Bytes ;
@@ -102,7 +100,7 @@ pub struct Ctx {
102
100
/// Indicates if this connection is being reused
103
101
pub connection_reused : bool ,
104
102
/// The location configuration handling this request
105
- pub location : Option < Arc < Location > > ,
103
+ pub location : String ,
106
104
/// Address of the upstream server
107
105
pub upstream_address : String ,
108
106
/// Client's IP address
@@ -131,7 +129,7 @@ pub struct Ctx {
131
129
pub cache_lock_time : Option < u64 > ,
132
130
/// Maximum time-to-live for cache entries
133
131
pub cache_max_ttl : Option < Duration > ,
134
- pub upstream : Option < Arc < Upstream > > ,
132
+ pub upstream : String ,
135
133
/// Indicates if the upstream connection is being reused
136
134
pub upstream_reused : bool ,
137
135
/// Number of requests being processed by upstream
@@ -309,8 +307,8 @@ impl Ctx {
309
307
}
310
308
} ,
311
309
"location" => {
312
- if let Some ( location ) = & self . location {
313
- buf. extend ( location . name . as_bytes ( ) )
310
+ if ! self . location . is_empty ( ) {
311
+ buf. extend ( self . location . as_bytes ( ) )
314
312
}
315
313
} ,
316
314
"connection_time" => {
@@ -395,10 +393,7 @@ pub fn get_cache_key(ctx: &Ctx, method: &str, uri: &Uri) -> CacheKey {
395
393
mod tests {
396
394
use super :: * ;
397
395
use bytes:: BytesMut ;
398
- use pingap_config:: LocationConf ;
399
- use pingap_location:: Location ;
400
396
use pretty_assertions:: assert_eq;
401
- use std:: sync:: Arc ;
402
397
use std:: time:: Duration ;
403
398
404
399
#[ test]
@@ -477,15 +472,7 @@ mod tests {
477
472
. as_ref( )
478
473
) ;
479
474
480
- ctx. location = Some ( Arc :: new (
481
- Location :: new (
482
- "pingap" ,
483
- & LocationConf {
484
- ..Default :: default ( )
485
- } ,
486
- )
487
- . unwrap ( ) ,
488
- ) ) ;
475
+ ctx. location = "pingap" . to_string ( ) ;
489
476
assert_eq ! (
490
477
b"pingap" ,
491
478
ctx. append_value( BytesMut :: new( ) , "location" ) . as_ref( )
0 commit comments