MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / from_path

Method from_path

graphlite/src/coordinator/query_coordinator.rs:71–116  ·  view source on GitHub ↗

Create a new QueryCoordinator from a database path (Simplified API) This is the recommended way to create a QueryCoordinator for embedding GraphLite. It handles all internal component initialization automatically. # Arguments `db_path` - Path to the database directory # Returns `Ok(Arc )` - Initialized coordinator ready for use `Err(String)` - Error message if initialization fa

(db_path: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

69 /// .expect("Failed to execute query");
70 /// ```
71 pub fn from_path(db_path: impl AsRef<Path>) -> Result<Arc<Self>, String> {
72 let path = db_path.as_ref().to_path_buf();
73
74 // Initialize storage
75 let storage = Arc::new(
76 StorageManager::new(path.clone(), StorageMethod::DiskOnly, StorageType::Sled)
77 .map_err(|e| format!("Failed to initialize storage: {}", e))?,
78 );
79
80 // Initialize catalog manager
81 let catalog_manager = Arc::new(RwLock::new(CatalogManager::new(storage.clone())));
82
83 // Initialize transaction manager with database path
84 let transaction_manager = Arc::new(
85 TransactionManager::new(path.clone())
86 .map_err(|e| format!("Failed to initialize transaction manager: {}", e))?,
87 );
88
89 // Initialize cache manager
90 let cache_config = crate::cache::CacheConfig::default();
91 let cache_manager =
92 Some(Arc::new(CacheManager::new(cache_config).map_err(|e| {
93 format!("Failed to initialize cache manager: {}", e)
94 })?));
95
96 // Create instance-based session provider (embedded mode)
97 let session_provider: Arc<dyn SessionProvider> = Arc::new(InstanceSessionProvider::new(
98 transaction_manager.clone(),
99 storage.clone(),
100 catalog_manager.clone(),
101 ));
102
103 // Create query executor
104 let executor = Arc::new(
105 QueryExecutor::new(
106 storage.clone(),
107 catalog_manager.clone(),
108 transaction_manager.clone(),
109 session_provider.clone(),
110 cache_manager,
111 )
112 .map_err(|e| format!("Failed to initialize query executor: {}", e))?,
113 );
114
115 Ok(Arc::new(Self::new(executor, session_provider)))
116 }
117
118 /// Create a new QueryCoordinator with specified session mode
119 ///

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected