Skip to content

Commit a56032b

Browse files
committed
stub out for rocksdb
1 parent e8d27b9 commit a56032b

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

link_aggregator/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ use tokio::runtime;
1212

1313
use consumer::consume;
1414
use server::serve;
15-
use storage::MemStorage;
15+
use storage::{MemStorage, RocksStorage};
1616

1717
fn main() -> Result<()> {
1818
println!("starting...");
1919

2020
let storage = MemStorage::new();
21+
let _ = RocksStorage::new(); // todo: switch storage to this
2122

2223
let qsize = Arc::new(AtomicU32::new(0));
2324

link_aggregator/src/storage/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ use links::CollectedLink;
55
pub mod mem_store;
66
pub use mem_store::MemStorage;
77

8+
pub mod rocks_store;
9+
pub use rocks_store::RocksStorage;
10+
811
/// consumer-side storage api, independent of actual storage backend
912
pub trait LinkStorage: StorageBackend {
1013
fn push(&self, event: &ActionableEvent) -> Result<()> {
@@ -48,8 +51,10 @@ mod tests {
4851
($test_name:ident, |$storage_label:ident| $test_code:block) => {
4952
#[test]
5053
fn $test_name() -> Result<()> {
51-
let __stores: Vec<(&str, Box<dyn LinkStorage>)> =
52-
vec![("memstorage", Box::new(MemStorage::new()))];
54+
let __stores: Vec<(&str, Box<dyn LinkStorage>)> = vec![
55+
("memstorage", Box::new(MemStorage::new())),
56+
("rocksdb", Box::new(RocksStorage::new())),
57+
];
5358
for (__backend_name, __storage) in __stores {
5459
println!("=> testing with {__backend_name} backend");
5560
let $storage_label = __storage;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use super::{LinkStorage, StorageBackend};
2+
use anyhow::Result;
3+
use link_aggregator::{Did, RecordId};
4+
use links::CollectedLink;
5+
6+
// hopefully-correct simple hashmap version, intended only for tests to verify disk impl
7+
#[derive(Debug, Clone)]
8+
pub struct RocksStorage(RocksStorageData);
9+
10+
#[derive(Debug, Clone)]
11+
struct RocksStorageData {}
12+
13+
impl RocksStorage {
14+
pub fn new() -> Self {
15+
Self(RocksStorageData {})
16+
}
17+
}
18+
19+
impl LinkStorage for RocksStorage {} // defaults are fine
20+
21+
impl StorageBackend for RocksStorage {
22+
fn add_links(&self, _record_id: &RecordId, _links: &[CollectedLink]) {
23+
todo!()
24+
}
25+
26+
fn set_account(&self, _did: &Did, _active: bool) {
27+
todo!()
28+
}
29+
30+
fn remove_links(&self, _record_id: &RecordId) {
31+
todo!()
32+
}
33+
34+
fn delete_account(&self, _did: &Did) {
35+
todo!()
36+
}
37+
38+
fn count(&self, _target: &str, _collection: &str, _path: &str) -> Result<u64> {
39+
todo!()
40+
}
41+
}

0 commit comments

Comments
 (0)