(config: Config, args: CosdataArgs)
| 18 | |
| 19 | impl AppContext { |
| 20 | pub fn new(config: Config, args: CosdataArgs) -> Result<Self, WaCustomError> { |
| 21 | let config = Arc::new(config); |
| 22 | let threadpool = Arc::new( |
| 23 | rayon::ThreadPoolBuilder::new() |
| 24 | .num_threads(config.thread_pool.pool_size) |
| 25 | .build() |
| 26 | .expect("Failed to build thread pool"), |
| 27 | ); |
| 28 | let ain_env = get_app_env(config.clone(), threadpool.clone(), args)?; |
| 29 | |
| 30 | let collections_path = get_data_path().join("collections"); |
| 31 | std::fs::create_dir_all(&collections_path) |
| 32 | .map_err(|e| WaCustomError::FsError(e.to_string()))?; |
| 33 | |
| 34 | let collection_cache_manager = Arc::new(CollectionCacheManager::new( |
| 35 | Arc::from(collections_path), |
| 36 | config.cache.max_collections, |
| 37 | config.cache.eviction_probability, |
| 38 | ain_env.clone(), |
| 39 | )); |
| 40 | |
| 41 | Ok(Self { |
| 42 | config, |
| 43 | ain_env, |
| 44 | threadpool, |
| 45 | collection_cache_manager, |
| 46 | }) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | use crate::models::collection_cache::CollectionCacheExt; |
nothing calls this directly
no test coverage detected