Skip to content

Commit 71d7526

Browse files
authored
Add leveldb-backed storage layer (#4)
* Add storage abstraction layer for metadata persistence * Add LevelDB-backed implementation of `MetadataStore`
1 parent 09cc44e commit 71d7526

7 files changed

Lines changed: 456 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 216 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ categories = ["database", "network-programming"]
1515

1616
[workspace.dependencies]
1717
thiserror = "2"
18+
tracing = "0.1"
19+
1820
base64 = "0.22"
1921
blake3 = "1.8"
2022
dashmap = "6.1"
2123
tokio = { version = "1.49", default-features = false }
24+
25+
# Chosen over `leveldb` crate which requires C++ LevelDB via FFI.
26+
rusty-leveldb = "1"

minikv-core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ categories.workspace = true
1212

1313
[dependencies]
1414
thiserror.workspace = true
15+
tracing.workspace = true
1516
base64 = { workspace = true }
1617
blake3 = { workspace = true }
1718
dashmap = { workspace = true }
19+
rusty-leveldb = { workspace = true }
1820

1921
[dev-dependencies]
2022
tokio = { workspace = true, features = ["full"] }

minikv-core/src/error.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Unified error type for minikv.
2+
#[derive(Debug, thiserror::Error)]
3+
pub enum Error {
4+
/// Errors from the rusty-leveldb storage engine.
5+
#[error("LevelDB error: {0}")]
6+
LevelDb(String),
7+
}
8+
9+
impl From<rusty_leveldb::Status> for Error {
10+
fn from(s: rusty_leveldb::Status) -> Self {
11+
Error::LevelDb(s.to_string())
12+
}
13+
}

minikv-core/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
pub mod error;
12
pub mod hashing;
23
pub mod locking;
4+
pub mod storage;
35
pub mod volumes;
6+
7+
pub use error::Error;

0 commit comments

Comments
 (0)