The details of OTP that you may have forgotten or never known!
For implementing the server of a client-server relation |
|
For implementing state machines |
|
For implementing event handling functionality |
|
For implementing a supervisor in a supervision tree |
| Application Types | |
|---|---|
Applications |
Regular applications that define their own supervision tree |
Libraries |
A simple collection of modules and doesn’t implement an application behavior callback module |
| Start Types | Affect on Runtime when Application Terminates |
|---|---|
|
Termination is reported but no other applications are terminated |
|
If application terminates abnormally all other applications and the runtime system are terminated |
|
All other applications and the runtime system are terminated |
The supervisor’s maximum restart intensity limits the number of restarts that can occur within an period of time. Restart intensity is specified as a map with two keys - intensity and period. Restarts are limited to the to number specified by intensity that occur within the number of seconds specified by period.
Child specs are maps with the following keys:
| Key | Optional | Description |
|---|---|---|
|
required |
An identifer to use for the process |
|
required |
The MFA to use to start the process |
|
optional |
See the restart types |
|
optional |
|
|
optional |
See the child types |
|
optional |
The callback module if there is one |
|
Any process that is not a supervisor |
|
A supervisor process |
|
The process is always restarted |
|
The process is never restarted |
|
The process is only restarted if it terminates abnormally |
| Strategy | Description |
|---|---|
|
If one child process crashes only restart that process |
|
If one child process crashes all other child processes are terminated and all of them are restarted |
|
If one child process crashes the rest of the child processes are terminated and the crashed process and other terminated processes are restarted |
|
Like the one_for_one strategy, but it can only dynamically start processes from a single child spec |