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

Function main

example/migrate_to_another_database.rs:3–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1
2#[tokio::main]
3async fn main() {
4
5
6 // path can be '.' in storage::open
7 let path = ".";
8
9 let storage_name = "blackbird";
10 let total_page_size = 1000;
11
12 // ** RamCopies **
13 // Dont log to disk and after shutdown , loss data
14
15 let stype = StorageType::RamCopies ;
16
17 // ** DiskCopies **
18 // whole storage operation is in-memory but log to disk,
19 // automatic load whole data after restart, avoid any loss data
20 //
21 // let stype = StorageType::DiskCopies;
22
23
24 let ops = Options::new(path, storage_name, total_page_size, StorageType::RamCopies, true);
25
26
27 // Storage is built for high concurrency usage
28 // dont need to Mutex / Rwlock, it is safe for shared between thread
29 //
30 // create storage and initialize other service (reporter, disk_log)
31 //
32 // when calling storage::open, it load whole storage from disk
33 //
34
35 let s = Arc::new(Storage::<Pid, User>::open(ops).await.unwrap());
36
37 let pw = Persistent::connect(DatabaseName::Postgres, "host=localhost user=postgres").await.unwrap();
38
39 // Copy Table to database
40 pw.copy_memtable_to_database(s.clone(), &WriteToDatabase).await;
41
42
43
44}
45
46
47struct WriteToDatabase;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected