mule/peer/cell

A crash-free, VM-global cell over persistent_term (FFI in mule_cell_ffi). The leader-election peer and Sonar write their current state here on each change; the cron/pruner/stager gates read it directly.

This exists because the only call primitive in this project’s gleam_erlang is process.call, which panics (not returns Error) when the callee is down, times out, or is an unregistered named subject. A gate that called the peer actor would crash its own process — cron, pruner, the stager — during any peer restart, cascading restarts. Reading a cell is a total, non-blocking, non-panicking operation that returns the supplied default when the key is absent.

Keys are namespaced strings (<kind>:<instance_name>) so two Mule instances in one VM do not collide. Values are stored as their native Gleam terms (Bool, Option(String), a Status variant), so the typed helpers in peer/sonar round-trip without an encoding step.

Values

pub fn get(key key: String, default default: value) -> value

Read the value under key, or default when the key has never been written. Never blocks, never panics.

pub fn put(key key: String, value value: value) -> Nil

Write value under key. A no-op when the stored value is already equal, so the global update cost is paid only on a real change.

Search Document