- m0p3: CONTRIBUTING.md with run-samples checklist, all 4 examples (quickstart, cli_embedding, axum_embedding, actix_embedding), doc-test coverage for every public API surface - m1p5: TidalDb public API — write_item, signal, read_decay_score, read_windowed_count, read_velocity; StorageBox enum routing memory vs fjall; WalSender/WalHandleWriter bridge; WAL replay on open - Periodic checkpoint: 30s background thread for persistent+schema mode; FjallBackend::Clone (O(1), fjall::Keyspace is ref-counted); graceful shutdown via Arc<AtomicBool> + join before final checkpoint - ROADMAP.md: M0 and M1 fully marked COMPLETE (341 tests passing) - Milestone 2 planning scaffolding added under docs/planning/milestone-2/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.4 KiB
Rust
40 lines
1.4 KiB
Rust
//! tidalDB quickstart: open an ephemeral database, verify health, and close.
|
|
//!
|
|
//! This example is the canonical first look at the tidalDB API. It compiles
|
|
//! as a live contract — if the builder or health-check API changes, this
|
|
//! example fails in CI.
|
|
//!
|
|
//! At M0 the database validates configuration and proves the builder works.
|
|
//! Future milestones will add signal writes, queries, and ranking here.
|
|
//!
|
|
//! # Running
|
|
//!
|
|
//! ```bash
|
|
//! cargo run --example quickstart --manifest-path tidal/Cargo.toml
|
|
//! ```
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Initialize tracing so spans emitted by tidalDB are visible.
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter("tidaldb=debug")
|
|
.init();
|
|
|
|
// Open an ephemeral (in-memory) database — no filesystem access.
|
|
// Use TidalDb::builder().with_data_dir(path) for persistent storage.
|
|
let db = tidaldb::TidalDb::builder().ephemeral().open()?;
|
|
|
|
// Verify the database handle is operational.
|
|
db.health_check()?;
|
|
|
|
println!("build: {}", tidaldb::BUILD_HASH);
|
|
println!("uptime: {:.3}s", db.metrics().uptime_seconds());
|
|
println!("health: ok");
|
|
|
|
// Explicit shutdown — also triggered automatically on drop.
|
|
// Future milestones: flushes WAL and storage engine here.
|
|
db.close()?;
|
|
|
|
println!("tidalDB opened, verified, and closed. M0 complete.");
|
|
Ok(())
|
|
}
|