Erlang 104 Otp-incomplete

Source: Internet
Author: User

Notes Series

Erlang Environment and sequential programming
Erlang Concurrent Programming
Erlang Distributed programming
Yaws
Erlang/otp

Date Change Description

2014-12-21 A Outline, 1

Agenda

0 Scope

Around the OTP design principles, record behavioral patterns, supervisory tree concepts, applications, releases and deployments, and a product-level caching solution in [3].

1 OTP Design Principles

Erlang Doc: OTP Design principles User ' s guide

The OTP design principle illustrates how Erlang code is organized in processes, modules, and directories.

1.1 Supervisory Tree (supervision Trees)

The ERLANG/OTP tree is a process organization model with two core entities: worker (worker) and Supervisor (supervisor).

The process of performing the actual work of the computational class;

Supervisor: Supervise the process of the worker's behavior, can restart the worker when the abnormality occurs;

Supervisory Tree: Organize your code into hierarchies based on workers and supervisors, and try to design and implement high-tolerance software.

Here is an example of a supervised tree, a square representing a supervisor, and a circle representing a worker.

1.2 Behavior mode (behaviours)

In the supervisory tree, many processes have similar structures, and formally say that their behavior follows similar patterns. For example, the difference between supervisors may be that they are different from the workers who oversee them, and the workers exhibit basic behavior similar to server/client, finite state machines (finite), or event handler.

The solution given by ERLANG/OTP is to divide the code of the process into two parts: one is generic (implemented by the behavior module) and the other is the special processing part of each process (implemented by the callback (callback) module).

The behavior module belongs to ERLANG/OTP. The standard ERLANG/OTP behavior includes:

Gen_server implementing the server in Server/client

GEN_FSM Realization of finite state machine

gen_event implementing event handling capabilities

Supervisor Implementation of supervisors in the supervisory tree

To implement the supervisor pattern, you only need to implement a predefined set of callback functions exported by the Supervisor behavior module. A bit like the template method design pattern Ah, more importantly, ERLANG/OTP is responsible for managing such as the supervisor process and worker process communication, interaction and other complex and boring functions of code implementation, debugging, product-level optimization and so on "dirty work", And we just need to open up the information to focus on the business-level implementation details.

1.3 Application (applications)

Components that implement some specific functionality are called applications (Applicaiton)in the ERLANG/OTP vocabulary. such as Mnesia, debugger and so on. The smallest ERLANG/OTP system is composed of kernel and stdlib applications.

The application concept applies to program structures (processes) and directory structures (modules).

The simplest class of applications does not contain any processes, only the function modules, which are called Library applications (libraries application), such as Stdlib.

Applications involving processes can be implemented through a supervised tree that uses standard behavior.

1.4 Release (releases)

Release is a complete system that contains ERLANG/OTP applications and user-specific applications.

How to install the release in target environment (target) in the System Principles section (see Erlang Doc: System Principles User's Guide).

1.5 Release processing (release handling)

The meaning of publishing processing is how to upgrade/downgrade in a different release version of the running system.

2 Behavioral Patterns

3 Applications

4 Monitoring tree-fault tolerance

5 Publishing and Deployment

6 Integration in Erlang

Reference documents

[1] Cesarini F., Thompson S., Munich ISAR working group CFRP confined translation.

Erlang Programming Guide .

Beijing: Mechanical industry Press. 2011.

[2] Armstrong J., into the translation of the cow.

Erlang Programming ( version 2 ). (Programming Erlang, Second edition–software for a Concurrent world).

Beijing: People's post and Telecommunications press. 2014.

[3] Logan M., Merritt E., Carlsson R., Liancheng.

ERLANG/OTP Concurrent Programming Combat . (Erlang and OTP in Action).

Beijing: People's post and telecommunications press. 2012.

Code:https://github.com/erlware/erlang-and-otp-in-action-source

Erlang 104 Otp-incomplete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.