Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
feat: sqlite-backed Storage implementation, SqliteStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantell committed Oct 19, 2023
1 parent 9e5c83b commit 7174731
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run_test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- name: 'Run Rust native target tests'
run: NOOSPHERE_LOG=deafening cargo test --features test-kubo,headers

run-test-suite-linux-rocksdb:
run-test-suite-linux-sqlite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -115,8 +115,8 @@ jobs:
with:
ipfs_version: v0.17.0
run_daemon: true
- name: 'Run Rust native target tests (RocksDB)'
run: NOOSPHERE_LOG=defeaning cargo test -p noosphere -p noosphere-storage --features rocksdb,test-kubo
- name: 'Run Rust native target tests (Sqlite)'
run: NOOSPHERE_LOG=defeaning cargo test -p noosphere -p noosphere-storage --features sqlite,test-kubo

run-test-suite-linux-c:
runs-on: ubuntu-latest
Expand Down
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rust/noosphere-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ libipld-cbor = { workspace = true }
serde = { workspace = true }
base64 = "=0.21.4"
url = { version = "^2" }
r2d2 = { version = "0.8.10", optional = true }
r2d2_sqlite = { version = "0.22.0", optional = true, features = ["bundled"] }

[dev-dependencies]
witty-phrase-generator = "~0.2"
Expand Down Expand Up @@ -69,6 +71,7 @@ features = [
default = []
rocksdb = ["dep:rocksdb"]
rocksdb-multi-thread = ["dep:rocksdb"]
sqlite = ["dep:r2d2", "dep:r2d2_sqlite"]

[[example]]
name = "bench"
14 changes: 9 additions & 5 deletions rust/noosphere-storage/examples/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ async fn create_sphere_with_large_files<S: Storage + 'static>(db: SphereDb<S>) -
type ActiveStoragePrimitive = noosphere_storage::SledStorage;
#[cfg(all(not(target_arch = "wasm32"), feature = "rocksdb"))]
type ActiveStoragePrimitive = noosphere_storage::RocksDbStorage;
#[cfg(all(
not(target_arch = "wasm32"),
feature = "sqlite",
not(feature = "rocksdb")
))]
#[cfg(all(not(target_arch = "wasm32"), feature = "sqlite"))]
type ActiveStoragePrimitive = noosphere_storage::SqliteStorage;
#[cfg(target_arch = "wasm32")]
type ActiveStoragePrimitive = noosphere_storage::IndexedDbStorage;
Expand Down Expand Up @@ -145,6 +141,14 @@ impl BenchmarkStorage {
)
};

#[cfg(all(not(target_arch = "wasm32"), feature = "sqlite"))]
let (storage, storage_name) = {
(
noosphere_storage::SqliteStorage::new(&storage_path)?,
"SqliteStorage",
)
};

#[cfg(target_arch = "wasm32")]
let (storage, storage_name) = {
let temp_name: String = witty_phrase_generator::WPGen::new()
Expand Down
5 changes: 5 additions & 0 deletions rust/noosphere-storage/src/implementation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ pub use rocks_db::*;
mod indexed_db;
#[cfg(target_arch = "wasm32")]
pub use indexed_db::*;

#[cfg(all(not(target_arch = "wasm32"), feature = "sqlite"))]
mod sqlite;
#[cfg(all(not(target_arch = "wasm32"), feature = "sqlite"))]
pub use sqlite::*;
Loading

0 comments on commit 7174731

Please sign in to comment.