2
2
3
3
//! A router based on the [`cluster::Cluster`].
4
4
5
- use std:: time:: Duration ;
6
-
7
5
use async_trait:: async_trait;
8
6
use ceresdbproto:: storage:: { Route , RouteRequest } ;
9
7
use cluster:: ClusterRef ;
@@ -24,8 +22,8 @@ impl ClusterBasedRouter {
24
22
let cache = if cache_config. enable {
25
23
Some (
26
24
Cache :: builder ( )
27
- . time_to_live ( Duration :: from_secs ( cache_config. ttl ) )
28
- . time_to_idle ( Duration :: from_secs ( cache_config. tti ) )
25
+ . time_to_live ( cache_config. ttl . 0 )
26
+ . time_to_idle ( cache_config. tti . 0 )
29
27
. max_capacity ( cache_config. capacity )
30
28
. build ( ) ,
31
29
)
@@ -114,6 +112,7 @@ impl Router for ClusterBasedRouter {
114
112
#[ cfg( test) ]
115
113
mod tests {
116
114
use std:: { collections:: HashMap , sync:: Arc , thread:: sleep} ;
115
+ use std:: time:: Duration ;
117
116
118
117
use ceresdbproto:: {
119
118
meta_event:: {
@@ -123,6 +122,7 @@ mod tests {
123
122
storage:: RequestContext ,
124
123
} ;
125
124
use cluster:: { Cluster , ClusterNodesResp } ;
125
+ use common_util:: config:: ReadableDuration ;
126
126
use meta_client:: types:: {
127
127
NodeShard , RouteEntry , RouteTablesResponse , ShardInfo , ShardRole :: Leader , TableInfo ,
128
128
TablesOfShard ,
@@ -216,8 +216,8 @@ mod tests {
216
216
217
217
let config = RouteCacheConfig {
218
218
enable : true ,
219
- ttl : 4 ,
220
- tti : 2 ,
219
+ ttl : ReadableDuration :: from ( Duration :: from_secs ( 4 ) ) ,
220
+ tti : ReadableDuration :: from ( Duration :: from_secs ( 2 ) ) ,
221
221
capacity : 2 ,
222
222
} ;
223
223
let router = ClusterBasedRouter :: new ( Arc :: new ( mock_cluster) , config) ;
0 commit comments