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

Method open

src/darkbird/storage_vector.rs:34–74  ·  view source on GitHub ↗
(ops: Options<'a>)

Source from the content-addressed store, hash-verified

32impl VecStorage
33{
34 pub async fn open<'a>(ops: Options<'a>) -> Result<Self, String> {
35
36 match DiskLog::open(ops.path, ops.storage_name, ops.total_page_size) {
37 Err(e) => return Err(e.to_string()),
38 Ok(disklog) => {
39 // Run DiskLog
40 let off_disk = if let StorageType::RamCopies = ops.stype { true } else { false };
41
42 // Run Reporter
43 let reporter = Router::<Event<VectorId, Vector>>::new(vec![]).unwrap().run_service();
44
45 // Run disk_log
46 let wal_session = disklog.run_service();
47
48
49 // Create VecStorage
50 let mut st = VecStorage {
51 vcache: DashMap::new(),
52 wal_session: wal_session,
53 reporter_session: reporter,
54 off_reporter: ops.off_reporter,
55 off_disk: true
56 };
57
58
59 // load from disk
60 if let Err(x) = st.loader().await {
61 if x != "End" {
62 return Err(x);
63 }
64 }
65
66
67 // because we want loader dont write to disk_log
68 st.off_disk = off_disk;
69
70 return Ok(st);
71 }
72 }
73
74 }
75
76 /// subscribe to Reporter
77 #[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