MCPcopy Create free account
hub / github.com/cosdata/cosdata / new

Method new

src/app_context.rs:20–47  ·  view source on GitHub ↗
(config: Config, args: CosdataArgs)

Source from the content-addressed store, hash-verified

18
19impl 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
50use crate::models::collection_cache::CollectionCacheExt;

Callers

nothing calls this directly

Calls 3

get_app_envFunction · 0.85
get_data_pathFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected