Diffinery

homeflare/celldpublic

celld/docs/library-api.md
60 lines · 2.7 KBRaw History
1# Rust library API
2
3## Select facade
4
5Use `celld::asyncrt::select!` when the source order must not decide a tie. The
6macro selects a cyclic start for each poll, and it rejects the `biased;` token.
7
8Use `celld::asyncrt::select_biased!` only when the source order defines the
9winner of a tie. The macro polls the branches in source order. The first token
10must be a non-empty string literal that states which arm wins and why.
11
12## Durability ownership
13
14The `celld` crate requires one `node_log::DurabilityOwner` for each local
15durability stack. The owner keeps the coupled registration. It retains each
16live or failed background-task handle until shutdown joins it. It also retains
17each admitted release-close task and the final close handle until the
18registered managed databases close.
19
20The crate removes these public functions:
21
22- `LtxRepl::set_shipper`
23- `LtxRepl::set_bundle_sink`
24- `node_log::spawn_maintenance`
25- `node_log::spawn_fragment_gc`
26
27The old setter functions installed separate strong references. A
28`NodeLogManager` also retains its `LtxRepl`, so these references can create an
29ownership cycle.
30
31The old spawn functions detached their task handles. An embedding process
32therefore cannot stop or join the tasks during local shutdown.
33
34Construct a `DurabilityOwner` after the node-log recovery completes. Call
35`DurabilityOwner::start_background` before the process starts its application
36services, and retain the owner for the process lifetime.
37
38Await `LtxRepl::release` when a runtime stops a cell and keeps its local files.
39The method admits a managed database close to the owner task group before it
40waits. Require an `Ok` result before another activation reuses the local path.
41The owner retains the admitted close if the caller is cancelled. An `Err`
42result retains the replica, so a later call can retry while the owner accepts
43close work. The final owner shutdown also closes a retained replica.
44
45Call `DurabilityOwner::quiesce_and_seal_within` with the remaining process time
46during shutdown. A `false` result means that the local fallback ran. Therefore,
47the process must not prepare a clean reload.
48
49Stop and join all application and runtime operations before the final local
50shutdown. This order prevents an activation from retaining an unregistered
51database across the final shutdown snapshot.
52
53Call `DurabilityOwner::shutdown_local_within` after an optional clean-reload
54preparation. Pass the remaining process time to this method. A `false` result
55means that the local fallback ran before the local shutdown completed, so the
56process must exit without unwinding.
57
58A process that has a follower store without a runtime durability stack must
59use `DurabilityOwner::new_follower`. This owner starts, stops, and joins the
60follower fragment collector.