File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,13 @@ use tokio::runtime;
1212
1313use consumer:: consume;
1414use server:: serve;
15- use storage:: MemStorage ;
15+ use storage:: { MemStorage , RocksStorage } ;
1616
1717fn 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
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ use links::CollectedLink;
55pub mod mem_store;
66pub 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
912pub 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;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments