src/CrashPoint.bend

mylsm-lsm-store@0.5.0.0 · 23 lines · 0 definitions

1import Base
2import mylsm-lsm-store@0.5.0.0/src/Console.bend as Console
3import mylsm-lsm-store@0.5.0.0/src/CrashPointPolicy.bend as Policy
4
5# Irreducible host boundary: emit an unbuffered marker and stop this process.
6def stop(name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
7  import "./effs/crash_point.c"
8  import "./effs/crash_point.js"
9
10# Resolve the hit for decision for the crash injection interface.
11def hit_decision(active: Bool, name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
12  match active:
13    case True{}:
14      stop(name)
15    case False{}:
16      IO.pure(Result<&1, &1, U32 & String, Unit>, Done{Unit{}})
17
18# Test-only checkpoint. Environment lookup and activation policy stay in Bend;
19# only marker emission and SIGSTOP remain in the host twins.
20def hit(+name: String) -> IO(Result<&1, &1, U32 & String, Unit>):
21  do IO<Result<&1, &1, U32 & String, Unit>>:
22    configured : String <- IO.try(String, Console.get_env("MYLSM_CRASH_POINT"))
23    hit_decision(Policy.enabled(configured, name), name)