Alarmist.Engine (alarmist v0.2.2)
View SourceSynthetic alarm processing engine
This module is intended for users extending the Alarmist DSL.
Summary
Types
:registered_rules
- map of alarm_id to its compiled rules:alarm_id_to_rules
- map of alarm_id to the list of rules to evaluate (inverse of:registered_rules
):cache
- temporary cache for alarm status while processing rules:changed_alarm_id
- list of alarm_ids that have changed values:timers
- map of alarm_id to pending timer:actions_r
- list of pending side effects in reverse (engine processing is side-effect free by design so someone else has to do the dirty work):states
- optional state that can be kept on a per-alarm_id basis:lookup_fun
- function for looking up alarm state
Functions
Create and add a synthetic alarm based on the rule specification
Cache alarm state and record the change
Commit all side effects from previous operations
Remove all of the rules associated with the specified id
Report that an alarm_id has changed state
Types
@type t() :: %Alarmist.Engine{ actions_r: [action()], alarm_id_to_rules: map(), cache: map(), changed_alarm_ids: [Alarmist.alarm_id()], lookup_fun: alarm_lookup_fun(), registered_rules: %{ required(Alarmist.alarm_id()) => Alarmist.compiled_rules() }, states: map(), timers: map() }
:registered_rules
- map of alarm_id to its compiled rules:alarm_id_to_rules
- map of alarm_id to the list of rules to evaluate (inverse of:registered_rules
):cache
- temporary cache for alarm status while processing rules:changed_alarm_id
- list of alarm_ids that have changed values:timers
- map of alarm_id to pending timer:actions_r
- list of pending side effects in reverse (engine processing is side-effect free by design so someone else has to do the dirty work):states
- optional state that can be kept on a per-alarm_id basis:lookup_fun
- function for looking up alarm state
Functions
@spec add_synthetic_alarm(t(), Alarmist.alarm_id(), Alarmist.compiled_rules()) :: t()
Create and add a synthetic alarm based on the rule specification
The synthetic alarm will be evaluated, so if the synthetic alarm ID already has subscribers, they'll get notified if the alarm is set.
@spec cache_put( t(), Alarmist.alarm_id(), Alarmist.alarm_state(), Alarmist.alarm_description() ) :: t()
Cache alarm state and record the change
IMPORTANT: Rules are evaluated on the next call to run/2
if there was a change.
@spec clear_alarm(t(), Alarmist.alarm_id()) :: t()
Commit all side effects from previous operations
The caller needs to run all of the side effects before the next call to the engine so state changes may be lost.
@spec handle_timeout(t(), Alarmist.alarm_id(), :set | :clear, reference()) :: t()
@spec init(alarm_lookup_fun()) :: t()
@spec remove_synthetic_alarm(t(), Alarmist.alarm_id()) :: t()
Remove all of the rules associated with the specified id
@spec set_alarm(t(), Alarmist.alarm_id(), Alarmist.alarm_description()) :: t()
Report that an alarm_id has changed state
@spec synthetic_alarm_ids(t()) :: [Alarmist.alarm_id()]