Annoyotron is a background event loop designed to nag active incidents for timely communications. It leverages short-lived finite state machines to determine when to send which nags.
Annoyotron maintains a set of nag states for each incident:
- mostRecentCommUpdate: Timestamp of the most recent communication update.
- lastNags: An object that stores timestamps for different types of nags, namely
noComms
,noPoint
, andneedCommUpdate
.
A nagMap
object stores the nag states indexed by the incidentId
. It serves as a simple memory for the Annoyotron by keeping track of the notifications already sent for incidents.
The invokeNags
function executes the nag operations on a given incident wrapped in an Annoyotron state machine.
It sends out messages through the provided robot.adapter
methods when conditions are met and updates the lastNags
timestamps accordingly.
The eventLoop
function performs the following actions:
- Fetches the most recent communication updates for incidents.
- Iterates over active incidents, checking if they require nagging based on priority and if mitigated or not.
- Initializes an Annoyotron state machine for the incidents not filtered out.
- Invokes nags based on the state machine.
Annoyotron requires minimal configuration. It uses a default loop interval of 42 seconds, which can be adjusted if needed via config.
The startAnnoyotron
function sets up a periodic interval using setInterval
that triggers the eventLoop
. It uses a predefined default loop interval but can also be configured using the system configuration.
The stopAnnoyotron
function is provided to clear the interval and stop the Annoyotron when it's no longer needed.