Skip to content

Commit 5134f65

Browse files
committed
add basic server implementation
1 parent e87f8c0 commit 5134f65

7 files changed

Lines changed: 536 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 106 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ slatedb = "0.9.1"
2525
thiserror = "2.0"
2626
tokio = { version = "1.0", features = ["full"] }
2727
tracing = "0.1"
28-
uuid = "1.14.0"
28+
tracing-subscriber = "0.3"
29+
uuid = "1.14.0"
30+
axum = "0.7"
31+
tower-http = { version = "0.5", features = ["cors"] }

open-tsdb/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ opendata-common.workspace = true
1313
slatedb.workspace = true
1414
tokio.workspace = true
1515
tracing.workspace = true
16+
tracing-subscriber.workspace = true
1617
serde.workspace = true
1718
serde_json.workspace = true
1819
thiserror.workspace = true
1920
uuid.workspace = true
21+
axum.workspace = true
22+
tower-http.workspace = true
2023

2124
blake3 = "1.8.2"
2225
promql-parser = "0.6"

open-tsdb/src/main.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ mod test_utils;
1313
mod tsdb;
1414
mod util;
1515

16-
fn main() {
17-
println!("open-tsdb: timeseries store");
16+
use std::sync::Arc;
17+
18+
use opendata_common::storage::in_memory::InMemoryStorage;
19+
20+
use promql::server::{PromqlServer, ServerConfig};
21+
use storage::merge_operator::OpenTsdbMergeOperator;
22+
use tsdb::Tsdb;
23+
24+
#[tokio::main]
25+
async fn main() {
26+
// Initialize tracing
27+
tracing_subscriber::fmt::init();
28+
29+
// Create in-memory storage with merge operator
30+
let storage = Arc::new(InMemoryStorage::with_merge_operator(Arc::new(
31+
OpenTsdbMergeOperator,
32+
)));
33+
34+
// Create Tsdb
35+
let tsdb = Arc::new(Tsdb::new(storage));
36+
37+
// Create and run server on default port (9090)
38+
let config = ServerConfig::default();
39+
let server = PromqlServer::new(tsdb, config);
40+
41+
println!("Starting open-tsdb Prometheus-compatible server on port 9090...");
42+
server.run().await;
1843
}

open-tsdb/src/promql/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ mod request;
55
mod response;
66
mod router;
77
pub(crate) mod selector;
8+
pub(crate) mod server;
89
mod tsdb_router;

0 commit comments

Comments
 (0)