- Add BUILD.bazel across tidal, tidal-net, tidal-server, tidalctl for bzlmod build - Add tidal/ crate docs (README, CHANGELOG, CONTRIBUTING, AGENTS, CLAUDE, API, ARCHITECTURE) and ai-lookup reference - Add docker standalone/cluster/deploy images, compose, and prometheus config - Harden WAL (batch format, writer, dedup, diagnostics), text syncer/collectors, and vector registry - Expand tidalctl CLI and tests; restructure WAL/visibility integration test suites - Refine tidal-net transport/client/server and tidal-server cluster/scatter-gather
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
//! tidalDB CLI embedding: open a persistent database and print status.
|
|
//!
|
|
//! Demonstrates:
|
|
//! - Opening a persistent `TidalDb` with an explicit data directory
|
|
//! - Printing build hash, uptime, and debug info
|
|
//! - Explicit `close()` before exit
|
|
//!
|
|
//! In a real CLI this data directory would come from a flag or config file.
|
|
//! Here we use a temporary directory so the example runs safely in CI.
|
|
//!
|
|
//! # Running
|
|
//!
|
|
//! ```bash
|
|
//! cargo run --example cli_embedding -p tidaldb
|
|
//! ```
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter("tidaldb=debug")
|
|
.init();
|
|
|
|
// Create a temporary directory to act as the data root.
|
|
// In a production CLI, replace this with the user-supplied path.
|
|
let tmp = tempfile::tempdir()?;
|
|
let data_dir = tmp.path();
|
|
|
|
let db = tidaldb::TidalDb::builder().with_data_dir(data_dir).open()?;
|
|
|
|
println!("build: {}", tidaldb::BUILD_HASH);
|
|
println!("data: {}", data_dir.display());
|
|
println!("uptime: {:.3}s", db.metrics().uptime_seconds());
|
|
println!("health: {:?}", db.health_check());
|
|
println!("debug: {db:?}");
|
|
|
|
// Explicit close — ensures any future WAL flush completes before exit.
|
|
db.close()?;
|
|
|
|
println!("shutdown complete.");
|
|
Ok(())
|
|
}
|