oxirs_fuseki/
lib.rs

1//! # OxiRS Fuseki - SPARQL HTTP Server
2//!
3//! [![Version](https://img.shields.io/badge/version-0.1.0-blue)](https://github.com/cool-japan/oxirs/releases)
4//! [![docs.rs](https://docs.rs/oxirs-fuseki/badge.svg)](https://docs.rs/oxirs-fuseki)
5//!
6//! **Status**: Production Release (v0.1.0)
7//! **Stability**: Public APIs are stable. Production-ready with comprehensive testing.
8//!
9//! SPARQL 1.1/1.2 HTTP protocol server with Apache Fuseki compatibility.
10//! Provides a production-ready HTTP interface for RDF data with query and update operations.
11//!
12//! ## Features
13//!
14//! - **SPARQL Protocol** - Full SPARQL 1.1 HTTP protocol implementation
15//! - **Query Endpoints** - SPARQL query execution via HTTP
16//! - **Update Operations** - SPARQL Update for data modification
17//! - **Dataset Management** - RESTful API for managing datasets
18//! - **Authentication** - Basic auth and OAuth2/OIDC support (in progress)
19//! - **Fuseki Compatibility** - Compatible with Fuseki configuration formats
20//!
21//! ## Quick Start
22//!
23//! ```rust,no_run
24//! use oxirs_fuseki::Server;
25//!
26//! #[tokio::main]
27//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
28//!     let server = Server::builder()
29//!         .port(3030)
30//!         .dataset_path("/data")
31//!         .build()
32//!         .await?;
33//!
34//!     server.run().await?;
35//!     Ok(())
36//! }
37//! ```
38//!
39//! ## See Also
40//!
41//! - [`oxirs-arq`](https://docs.rs/oxirs-arq) - SPARQL query engine
42//! - [`oxirs-core`](https://docs.rs/oxirs-core) - RDF data model
43
44use 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
105// Additional Production Features
106pub mod cdn_static;
107pub mod edge_caching;
108pub mod load_balancing;
109
110use store::Store;
111
112/// SPARQL HTTP server implementation
113pub struct Server {
114    addr: SocketAddr,
115    store: Store,
116    config: config::ServerConfig,
117}
118
119impl Server {
120    /// Create a new server builder
121    pub fn builder() -> ServerBuilder {
122        ServerBuilder::new()
123    }
124
125    /// Run the server
126    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
135/// Server builder for configuration
136pub 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}