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

Function main

example/new_features_vsn2.rs:3–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1
2#[tokio::main]
3async fn main() {
4
5 let path = ".";
6 let storage_name = "blackbird";
7 let total_page_size = 1000;
8
9 let stype = StorageType::RamCopies ;
10 let ops = Options::new(path, storage_name, total_page_size, StorageType::RamCopies, true);
11
12
13 // **** Performance Improve vsn-2 ****
14 //
15 // Prev version :
16 // when insert key/doc, clone (key, document) for
17 // send to reporter channel EVEN if not EXIST ANY subscriber
18 //
19 // New version : ( ``` off_reporter() ``` )
20 // if reporter is off dont clone
21 //
22
23 let s = Arc::new(Storage::<Pid, User>::open(ops)
24 .await
25 .unwrap()
26 .off_reporter());
27
28
29 s1.insert("+98 9370156893".to_owned(), User::new("DanyalMh1")).await;
30 s1.insert("+98 939.......".to_owned(), User::new("DanyalMh2")).await;
31 s1.insert("+98 939.......".to_owned(), User::new("DanyalMh3")).await;
32
33
34
35 // **** New Feature vsn-2 ****
36 //
37 // Note:
38 // Persistent Getter and Setter is complete safe,
39 // can run Insert/Remove/Lookup on storage also
40 // concurrently call (copy_memtable_to_database) and (load_memtable_from_database) in that
41 //
42 //
43 let cfg_string = "host=localhost user=postgres".to_string();
44 let pers = Persistent::connect(DatabaseName::Postgres, cfg_string).await.unwrap();
45 let h = Handler;
46
47 h.init().await;
48
49 // Copy table to postgres
50 pers.copy_memtable_to_database(s1, &h).await;
51
52
53 // Load table from postgres
54 pers.load_memtable_from_database(s1, &h).await;
55}
56
57
58struct Handler;

Callers

nothing calls this directly

Calls 5

initMethod · 0.80
insertMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected