Write once global flags for Erlang and Elixir.
This module provides a very simple API for managing global flags and conditional execution based on those flags. This is designed for setups where you need quick flag checks before execution, but don't want to waste a process, start an ETS table, and cannot rely on the process dictionary.
It works by using a super simple atom table check, which makes the check almost instant (and without having to rely on any prior state).
Flags cannot be unset after being set, due to the inability to purge from the atom table. If you want such ability, you likely want to deal with ETS or some other storage.| is_set/1 | Checks if a global flag is set. |
| once/2 | Runs a function a single time, based on the provided flag. |
| set/1 | Sets a global flag, typically only used internally. |
| with/2 | Runs a function only if the provided flag is set. |
| without/2 | Runs a function only if the provided flag is not set. |
is_set(Flag::binary() | list()) -> boolean()
Checks if a global flag is set.
once(Flag::binary() | list(), Fun::fun(() -> any())) -> any | {error, flag_state}
Runs a function a single time, based on the provided flag.
set(Flag::binary() | list()) -> ok
Sets a global flag, typically only used internally.
with(Flag::binary() | list(), Fun::fun(() -> any())) -> any | {error, flag_state}
Runs a function only if the provided flag is set.
without(Flag::binary() | list(), Fun::fun(() -> any())) -> any | {error, flag_state}
Runs a function only if the provided flag is not set.
Generated by EDoc