1use std::net::SocketAddr;
45
46pub mod adaptive_execution;
47pub mod admin_ui;
48pub mod aggregation;
49pub mod analytics;
50pub mod api;
51pub mod auth;
52pub mod backup;
53pub mod batch_execution;
54pub mod bind_values_enhanced;
55pub mod clustering;
56pub mod concurrent;
57pub mod config;
58#[cfg(feature = "hot-reload")]
59pub mod config_reload;
60pub mod connection_pool;
61pub mod consciousness;
62pub mod dataset_management;
63pub mod ddos_protection;
64pub mod disaster_recovery;
65pub mod error;
66pub mod federated_query_optimizer;
67pub mod federation;
68pub mod gpu_kg_embeddings;
69pub mod graph_analytics;
70pub mod graphql_integration;
71pub mod handlers;
72pub mod health;
73pub mod http_protocol;
74pub mod ids;
75pub mod k8s_operator;
76pub mod memory_pool;
77pub mod metrics;
78pub mod middleware;
79pub mod middleware_integration;
80pub mod optimization;
81pub mod performance;
82pub mod performance_profiler;
83pub mod production;
84pub mod property_path_optimizer;
85pub mod query_cache;
86pub mod realtime_notifications;
87pub mod recovery;
88pub mod rest_api_v2;
89pub mod security_audit;
90pub mod server;
91pub mod simd_triple_matcher;
92pub mod sparql_simd_integration;
93pub mod store;
94pub mod store_ext;
95pub mod store_health;
96pub mod store_impl;
97pub mod streaming;
98pub mod streaming_results;
99pub mod subquery_optimizer;
100pub mod tls;
101pub mod tls_rotation;
102pub mod vector_search;
103pub mod websocket;
104
105pub mod cdn_static;
107pub mod edge_caching;
108pub mod load_balancing;
109
110use store::Store;
111
112pub struct Server {
114 addr: SocketAddr,
115 store: Store,
116 config: config::ServerConfig,
117}
118
119impl Server {
120 pub fn builder() -> ServerBuilder {
122 ServerBuilder::new()
123 }
124
125 pub async fn run(self) -> Result<(), Box<dyn std::error::Error>> {
127 let runtime = server::Runtime::new(self.addr, self.store, self.config);
128 runtime
129 .run()
130 .await
131 .map_err(|e| Box::new(e) as Box<dyn std::error::Error>)
132 }
133}
134
135pub struct ServerBuilder {
137 port: u16,
138 host: String,
139 dataset_path: Option<String>,
140}
141
142impl ServerBuilder {
143 pub fn new() -> Self {
144 ServerBuilder {
145 port: 3030,
146 host: "localhost".to_string(),
147 dataset_path: None,
148 }
149 }
150
151 pub fn port(mut self, port: u16) -> Self {
152 self.port = port;
153 self
154 }
155
156 pub fn host(mut self, host: impl Into<String>) -> Self {
157 self.host = host.into();
158 self
159 }
160
161 pub fn dataset_path(mut self, path: impl Into<String>) -> Self {
162 self.dataset_path = Some(path.into());
163 self
164 }
165
166 pub async fn build(self) -> Result<Server, Box<dyn std::error::Error>> {
167 let addr: SocketAddr = format!("{}:{}", self.host, self.port).parse()?;
168 let store = if let Some(path) = self.dataset_path {
169 Store::open(path)?
170 } else {
171 Store::new()?
172 };
173
174 let config = config::ServerConfig::default();
175
176 Ok(Server {
177 addr,
178 store,
179 config,
180 })
181 }
182}
183
184impl Default for ServerBuilder {
185 fn default() -> Self {
186 Self::new()
187 }
188}