File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1- use std:: collections:: {
2- BTreeMap ,
3- HashMap ,
1+ use std:: {
2+ collections:: {
3+ BTreeMap ,
4+ HashMap ,
5+ } ,
6+ sync:: atomic:: {
7+ AtomicU64 ,
8+ Ordering ,
9+ } ,
410} ;
511
612use async_trait:: async_trait;
@@ -135,12 +141,14 @@ type HandlerFn = Box<
135141
136142pub struct StaticFetchClient {
137143 router : BTreeMap < url:: Url , HashMap < http:: Method , HandlerFn > > ,
144+ num_calls : AtomicU64 ,
138145}
139146
140147impl StaticFetchClient {
141148 pub fn new ( ) -> Self {
142149 Self {
143150 router : BTreeMap :: new ( ) ,
151+ num_calls : AtomicU64 :: new ( 0 ) ,
144152 }
145153 }
146154
@@ -156,11 +164,17 @@ impl StaticFetchClient {
156164 . or_default ( )
157165 . insert ( method, Box :: new ( handler) ) ;
158166 }
167+
168+ /// Returns how many times a fetch client has been called
169+ pub fn num_calls ( & self ) -> u64 {
170+ self . num_calls . load ( Ordering :: Relaxed )
171+ }
159172}
160173
161174#[ async_trait]
162175impl FetchClient for StaticFetchClient {
163176 async fn fetch ( & self , request : HttpRequestStream ) -> anyhow:: Result < HttpResponseStream > {
177+ self . num_calls . fetch_add ( 1 , Ordering :: Relaxed ) ;
164178 let handler = self
165179 . router
166180 . get ( & request. url )
Original file line number Diff line number Diff line change @@ -1058,3 +1058,10 @@ pub static REQUEST_TRACE_SAMPLE_CONFIG: LazyLock<SamplingConfig> =
10581058/// the "backend_startup" domain keyed by db cluster name.
10591059pub static STARTUP_RATE_LIMIT_ENABLED : LazyLock < bool > =
10601060 LazyLock :: new ( || env_config ( "STARTUP_RATE_LIMIT_ENABLED" , false ) ) ;
1061+
1062+ /// Size of the cache for access token authentication
1063+ pub static AUTH_CACHE_SIZE : LazyLock < usize > = LazyLock :: new ( || env_config ( "AUTH_CACHE_SIZE" , 1000 ) ) ;
1064+
1065+ /// Length of time an entry to the access authentication cache is valid
1066+ pub static AUTH_CACHE_TTL_SECONDS : LazyLock < u64 > =
1067+ LazyLock :: new ( || env_config ( "AUTH_CACHE_TTL_SECONDS" , 60 ) ) ;
You can’t perform that action at this time.
0 commit comments