okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffauffeat(daemon): add native storage helper modes159a58a

main
788 B34 linesraw
1//// Deterministic effect gates for helper lifetime tests; never shipped.
2
3import albedo/daemon/storage_cli
4import gleam/erlang/process
5
6@external(erlang, "albedo_storage_test_support", "signal")
7fn signal(operation: String, path: String) -> Nil
8
9pub fn main() -> Nil {
10  let assert [operation, home, path] = storage_cli.arguments()
11  storage_cli.maintain(
12    home,
13    fn(file) {
14      case operation {
15        "delete" -> gate(operation, path)
16        _ -> Nil
17      }
18      storage_cli.remove(file)
19    },
20    fn(file) {
21      case operation {
22        "vacuum" -> gate(operation, path)
23        _ -> Nil
24      }
25      storage_cli.vacuum(file)
26    },
27  )
28  |> storage_cli.finish
29}
30
31fn gate(operation: String, path: String) -> Nil {
32  signal(operation, path)
33  process.sleep_forever()
34}