View Source Alarmist (alarmist v0.1.2)

Alarm manager

Summary

Types

Alarm information

Alarm identifier

Alarm state

Functions

Add a rule-based alarm

Manually add a rule-based alarm

Return all of the currently set alarms

Manually add a rule-based alarm

Subscribe to alarm status events

Unsubscribe the current process from the specified alarm :set and :clear events

Types

@type alarm() :: {alarm_id(), any()}

Alarm information

Calls to :alarm_handler.set_alarm/1 pass an alarm identifier and data as a 2-tuple. Alarmist stores the data of the most recent call.

:alarm_handler.set_alarm/1 doesn't enforce the use of 2-tuples. Alarmist normalizes alarms that don't have data to ones that have an empty list.

@type alarm_id() :: atom()

Alarm identifier

Alarm identifiers are the unique identifiers of each alarm that can be set or cleared. Alarms also contain data, but the data is informational about the most recent call to :alarm_handler.set_alarm/1.

While SASL alarm identifiers can be anything, Alarmist imposes the restriction that they all be atoms. It is highly recommended to use module names to avoid naming collisions. Non-atom alarms are currently ignored by Alarmist.

@type alarm_state() :: :set | :clear

Alarm state

Alarms are in the :set state after a call to :alarm_handler.set_alarm/1 and in the :clear state after a call to :alarm_handler.clear_alarm/1. Redundant calls to :alarm_handler.set_alarm/1 update the alarm data and redundant calls to :alarm_handler.clear_alarm/1 are ignored.

@type compiled_rules() :: [Alarmist.Compiler.rule()]

Functions

Link to this function

add_synthetic_alarm(alarm_id)

View Source
@spec add_synthetic_alarm(module()) :: :ok

Add a rule-based alarm

After this call, Alarmist will watch for alarms to be set based on the supplied rules and set or clear the specified alarm ID. The alarm ID needs to be unique.

Link to this function

add_synthetic_alarm(alarm_id, compiled_rules)

View Source
@spec add_synthetic_alarm(alarm_id(), compiled_rules()) :: :ok

Manually add a rule-based alarm

Use this when not using defalarm.

After this call, Alarmist will watch for alarms to be set based on the supplied rules and set or clear the specified alarm ID. The alarm ID needs to be unique.

@spec current_alarms() :: [alarm_id()]

Return all of the currently set alarms

Link to this function

remove_synthetic_alarm(alarm_id)

View Source
@spec remove_synthetic_alarm(alarm_id()) :: :ok

Manually add a rule-based alarm

Use this when not using defalarm.

After this call, Alarmist will watch for alarms to be set based on the supplied rules and set or clear the specified alarm ID. The alarm ID needs to be unique.

@spec subscribe(alarm_id()) :: :ok

Subscribe to alarm status events

Events will be delivered to the calling process as:

%PropertyTable.Event{
  table: Alarmist,
  property: [TheAlarmId, :status],
  value: :set,
  timestamp: -576460718306150542,
  previous_value: nil,
  previous_timestamp: nil
}

This will almost certainly change in the future to avoid exposing that the PropertyTable library is used to manage subscriptions.

@spec unsubscribe(alarm_id()) :: :ok

Unsubscribe the current process from the specified alarm :set and :clear events