OTP

OPT design principles

A key advantage for using Erlang to construct large fault-tolerant systems is the Open Telecoms Platform (OTP) framework. This is a set of libraries that allow the construction of applications as SUPERVISION TREES, which break up the processes used in the application into:

The supervision tree is the hierarchical arrangement of code into supervisors and workers. This is possible because most of the modules in the application behave as one of a small finite set of patterns (behaviours):

Behaviours are implemented as callback modules, ie the developer writes a set of functions that the behaviour calls in order to carry out its task. For example a gen_server module must export the functions init/1, handle_cast/2, handle_info/2, terminate/2, code_change/3 and handle_call/3. Since gen_servers usually make up the bulk of an application (Joe Armstrong thesis) consider the gen_server callbacks in detail below:

The first three callbacks are the main ones to implement to get an application up and running, the others can be initially just put in as skeletons that don't do any processing and just return the required result.