src/CrashPoint.bend
mylsm-lsm-store@0.3.2.0 · 31 lines · 5 definitions
1import Base
2import mylsm-lsm-store@0.3.2.0/src/Console.bend as Console
3
4
5
6def nonempty(value: String) -> Bool:
7 match value:
8 case SNil{}: False{}
9 case SCon{_, _}: True{}
10
11def enabled(+configured: String, requested: String) -> Bool:
12 Bool.and(nonempty(configured), String.eq(configured, requested))
13
14
15def stop(name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
16 import "./effs/crash_point.c"
17 import "./effs/crash_point.js"
18
19def hit_decision(active: Bool, name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
20 match active:
21 case True{}:
22 stop(name)
23 case False{}:
24 IO.pure(Result<&1, &1, U32 & String, Unit>, Done{Unit{}})
25
26
27
28def hit(+name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
29 do IO<Result<&1, &1, U32 & String, Unit>>:
30 configured : String <- IO.try(String, Console.get_env("MYLSM_CRASH_POINT"))
31 hit_decision(enabled(configured, name), name)