📜 ⬆️ ⬇️

Introduction to the Open Telecom Platform / Open Telecommunication Platform (OTP / OTP)

Prehistory

Many people refer to Erlang as "Erlang / OTP". OTP means the Open Telecommunication Platform and is no more, no less, a set of libraries that come with Erlang. They consist of Erlang-interfaces (or behaviors, behavioral English), which are necessary when writing servers, state machines, event managers (or dispatchers). But that's not all, OTP also includes an Application interface, which allows programmers to package their code in one “application”. A Supervisor interface gives programmers the ability to create a hierarchical process tree, where, if a process dies, it will be restarted.

OTP is too complicated to talk about in one article, and I will not try to do it, instead of which I will write a series of articles in a couple of weeks.
')

Why should I find out about Erlang / OTP?



The platform that comes with Erlang gives you a rich and very generalized set of libraries and interfaces with which you can easily create high-load, fault-tolerant, hot-swappable code systems. The following is a list of things you get “for nothing”:

In addition to these “free” features, OTP offers a standardized approach to building applications on Erlang. All known open source applications, such as ejabberd , CouchDB , and MochiWeb , use OTP.

Therefore, studying OTP, you not only gain knowledge and the ability to create the most powerful Erlang systems, but you can immediately join open source projects and gain knowledge and experience there, as they follow the same general structure.

If you know the general syntax of Erlang, then you are ready to start learning Erlang / OTP!

Interfaces gen_ *:



Supervisor interface


The process implements the supervisor interface to describe its child processes that it will manage. The set of supervisors (control processes) is combined into a hierarchical tree of supervisors. If the child process dies, the supervisor knows what to do with it, how and when to restart, etc. Thus, your processes are always afloat.

For a more complete understanding of the Supervisor interface, read this page from the Erlang documentation.

Application interface


The Application interface is needed in order to start and stop many supervisors and other processes as one unit. For example, after creating my SOCKS5 server, I packed it all into Application, which started with the application:start(socks5_server) command application:start(socks5_server) .

To learn more about the Application interface, pay attention to the introduction from the Erlang documentation.

What to expect in the future?


This post was conceived as a brief introduction to OTP. Also, to answer questions such as “Why should I study this?”. Finally, to let you know where and how you can start. In the coming days, I will publish a series of articles in which we will gradually create an OTP application.

My next article, which I will show tomorrow, will contain an introduction to gen_server, where we will write a theoretical bank account manager. By the end of 2 weeks you will know how to create your own Erlang / OTP application from scratch.

Continued: Introduction to gen_server: "Erlybank"

Source: https://habr.com/ru/post/55657/


All Articles