Skip to main content

chronix_engine/objstore/
mod.rs

1//! Object storage backend for Chronix.
2//!
3//! Provides cloud-compatible segment storage (S3, GCS, Azure Blob Storage)
4//! implementing the [`crate::storage::StorageBackend`] trait, with an
5//! optional local disk cache for frequently accessed segments.
6//!
7//! # Quick Start
8//!
9//! ```rust,no_run
10//! use chronix_engine::objstore::{ObjectStoreBackend, ObjectStoreConfig};
11//! use chronix_engine::storage::StorageBackend;
12//!
13//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
14//! // S3 backend with 1 GB local cache
15//! let config = ObjectStoreConfig {
16//!     url: "s3://my-bucket/chronix-data".into(),
17//!     cache: Some(crate::objstore::CacheConfig {
18//!         cache_dir: "/tmp/chronix-cache".into(),
19//!         max_size_bytes: 1024 * 1024 * 1024,
20//!     }),
21//!     multipart_threshold_bytes: 8 * 1024 * 1024, // 8 MiB
22//!     max_concurrent_downloads: 8,
23//! };
24//!
25//! let backend = ObjectStoreBackend::new(config).await?;
26//!
27//! // Use it like any StorageBackend
28//! let path = crate::storage::SegmentPath::new(
29//!     chronix_core::NamespaceId::default_namespace(),
30//!     chronix_core::ShardId(1),
31//!     "seg_001.csx",
32//! )?;
33//! backend.put_segment(&path, b"segment data").await?;
34//! # Ok(())
35//! # }
36//! ```
37//!
38//! # URL Schemes
39//!
40//! | Scheme     | Backend            | Example                              |
41//! |------------|--------------------|--------------------------------------|
42//! | `s3://`    | Amazon S3          | `s3://bucket/prefix`                 |
43//! | `gs://`    | Google Cloud       | `gs://bucket/prefix`                 |
44//! | `az://`    | Azure Blob Storage | `az://container/prefix`              |
45//! | `file://`  | Local filesystem   | `file:///tmp/data`                   |
46//! | `memory://`| In-memory (tests)  | `memory://test`                      |
47//! | `/path`    | Local filesystem   | `/tmp/data`                          |
48
49#![warn(missing_docs)]
50#![deny(unsafe_code)]
51
52pub mod backend;
53pub mod cache;
54pub mod error;
55pub mod parquet_tier;
56pub mod tiering;
57
58pub use backend::{BackoffConfig, ObjectStoreBackend, ObjectStoreConfig};
59pub use cache::{CacheConfig, DiskCache};
60pub use error::{ObjStoreError, Result};
61pub use parquet_tier::{parquet_to_batches, ParquetArchiveWriter};
62pub use tiering::{ArchiveObject, TieringConfig, TieringEngine};