Handling failure
In a distributed system, it's customary to fail fast and let other processes deal with failure. This principle is encouraged in Erlang, from which Cloud Haskell is modelled. We should be prepared for an arbitrary process crashing, with its parent or monitoring process handling the failure (or propagating it further to a parent's parent).
There are two tactics to be noted about process failure in Cloud Haskell: linking and monitoring. The difference is that a linked process propagates exceptions to its parent, while an exception in a monitored process results in the monitoring process receiving a ProcessMonitorNotification
message.
Firing up monitors
The basic monitoring API is the following:
monitor :: ProcessId → Process MonitorRef monitorNode :: NodeId → Process MonitorRef monitorPort :: SendPort a → Process MonitorRef unmonitor :: MonitorRef → Process () withMonitor :: ProcessId → Process a → Process a
We can...