MCPcopy Create free account
hub / github.com/Rustixir/darkbird / open

Method open

src/darkbird/storage.rs:61–105  ·  view source on GitHub ↗
(ops: Options<'a>)

Source from the content-addressed store, hash-verified

59 + 'static,
60{
61 pub async fn open<'a>(ops: Options<'a>) -> Result<Self, String> {
62
63 match DiskLog::open(ops.path, ops.storage_name, ops.total_page_size) {
64 Err(e) => return Err(e.to_string()),
65 Ok(disklog) => {
66 // Run DiskLog
67 let off_disk = if let StorageType::RamCopies = ops.stype { true } else { false };
68
69 // Run Reporter
70 let reporter = Router::<Event<K, Doc>>::new(vec![]).unwrap().run_service();
71
72 // Run disk_log
73 let wal_session = disklog.run_service();
74
75
76 // Create Storage
77 let mut st = Storage {
78 collection: DashMap::new(),
79 hash_index: HashIndex::new(),
80 tag_index: TagIndex::new(),
81 range_index: RangeIndex::new(),
82 inverted_index: InvertedIndex::new(),
83 wal_session: wal_session,
84 reporter_session: reporter,
85 off_reporter: ops.off_reporter,
86 off_disk: true
87 };
88
89
90 // load from disk
91 if let Err(x) = st.loader().await {
92 if x != "End" {
93 return Err(x);
94 }
95 }
96
97
98 // because we want loader dont write to disk_log
99 st.off_disk = off_disk;
100
101 return Ok(st);
102 }
103 }
104
105 }
106
107 /// subscribe to Reporter
108 #[inline]

Callers

nothing calls this directly

Calls 3

to_stringMethod · 0.45
run_serviceMethod · 0.45
loaderMethod · 0.45

Tested by

no test coverage detected