This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By default, GenEvent event handlers fail silently and are not automatically restarted. Not good. | |
# There's an easy enough way to correct this. | |
# You'll need to | |
# 1. define a supervised event manager as a GenServer, | |
# 2. register its GenEvent handlers with monitoring enabled | |
# 3. catch handler exits as "out of band" messages (handle_info) | |
# 4. stop the event manager when any handler crashes, relying on the supervisor to restart the event | |
# manager who will then restart all of its GenEvent handlers. | |
# This approach assumes that event handling is either stateless or can reset its state without issues. |