otp

Erlang: supervisor(3), adding a child process

╄→尐↘猪︶ㄣ 提交于 2019-12-03 07:17:00
问题 Where can I find example on how to add dynamic child processes to an existing supervisor ( simple_one_for_one restart strategy) ? 回答1: I did some research, and below is what I have. First, this is a sample callback module of a supervisor: -module(root_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). start_link() -> {ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, []), {ok, Pid}. init(_Args) -> RestartStrategy = {simple_one_for_one, 10, 60}, ChildSpec =

SOA: Why do not use Erlang/OTP web servers as services?

百般思念 提交于 2019-12-03 06:57:25
After reading the Service Oriented Architecture Principles site and the respective Wikipedia article I had a thought: the Erlang/OTP platform can be considered as an SOA platform and SOA applications can be built on it. The only thing is that the Service Contract for each service in such a system is very specific: in order to call a service in Erlang/OTP the Orchestrating layer would have to make calls via Erlang messages or calls to gen_server (depends on the implementation). This would not let making any calls to the services outside of Erlang/OTP platform scope. But what if we try to build

Erlang/OTP architecture: RESTful protocol for SOAish services

时光总嘲笑我的痴心妄想 提交于 2019-12-03 06:57:08
Let us imagine we have an orders processing system for a pizza shop to design and build. The requirements are: R1. The system should be client- and use-case-agnostic, which means that the system can be accessed by a client which was not taken into account during the initial design. For example, if the pizza shop decides that many of its customers use the Samsung Bada smartphones later, writing a client for Bada OS will not require rewriting the system's API and the system itself; or for instance, if it turns out that using iPads instead of Android devices is somehow better for delivery drivers

Using OTP/Erlang as a part of the component-based architecture of a web application

我们两清 提交于 2019-12-03 00:17:53
I have an Erlang/OTP application which does some business logic. It is written in Erlang mostly for fault-tolerance, because I can easily restart one of the crashed components of the system (high uptime is the most important requirement). Each of its components does some sort of specific "parallel" computations. As a result of one working cycle the application produces a list of values. Let's call this Erlang/OTP application a "back-end". This Erlang/OTP application would also use a PostgreSQL server to store the results in the persistent storage and to store additional meta-information needed

Non-blocking TCP server using OTP principles

雨燕双飞 提交于 2019-12-03 00:13:54
I'm starting to learn Erlang, so I'm trying to write the "hello, world!" of concurrent programming, an IRC bot. I've already written one using Erlang without any OTP niceties (supervisor, application, etc. behaviours). I'm looking to rewrite it using OTP principles but unfortunately I can't figure out the "right" way to do socket programming with OTP. It seems the only reasonable way is to create another process manually and link it to the supervisor, but surely someone, somewhere, has done this before. I think this is what you're looking for: http://www.trapexit.org/Building_a_Non-blocking

What's the best way to run a gen_server on all nodes in an Erlang cluster?

夙愿已清 提交于 2019-12-02 23:42:01
I'm building a monitoring tool in Erlang . When run on a cluster, it should run a set of data collection functions on all nodes and record that data using RRD on a single "recorder" node. The current version has a supervisor running on the master node ( rolf_node_sup ) which attempts to run a 2nd supervisor on each node in the cluster ( rolf_service_sup ). Each of the on-node supervisors should then start and monitor a bunch of processes which send messages back to a gen_server on the master node ( rolf_recorder ). This only works locally. No supervisor is started on any remote node. I use the

Erlang: supervisor(3), adding a child process

我与影子孤独终老i 提交于 2019-12-02 22:05:51
Where can I find example on how to add dynamic child processes to an existing supervisor ( simple_one_for_one restart strategy) ? I did some research, and below is what I have. First, this is a sample callback module of a supervisor: -module(root_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). start_link() -> {ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, []), {ok, Pid}. init(_Args) -> RestartStrategy = {simple_one_for_one, 10, 60}, ChildSpec = {ch1, {ch1, start_link, []}, permanent, brutal_kill, worker, [ch1]}, Children = [ChildSpec], {ok,

Generate secret code for password reset

你。 提交于 2019-12-02 17:19:30
I'm doing a module which allow users to reset password. I noticed how most websites they provide a confirmation link which contain query string that has a unique hash. My question is: How can I generate this unique hash each time the same user request forgot password? Should I store this hash in database and use it for verification later on? Will it be safe? Or should I create some sort of algorithm which generate one-time password? How can I generate a OTP? Artefacto Yes, you should Generate a random reset token. See e.g. this answer . Store it in the database (possibly with an expiry time)

Erlang/OTP behaviors for beginner

帅比萌擦擦* 提交于 2019-12-02 17:07:15
As I understood from the "Erlang and OTP in action" book, the word behavior refers to: the behaviour interface, which is a set of functions; the behaviour implementation, which is the application-specific code (a callback module); the behaviour container, which is a process. Question: What an Erlang/OTP beginner should know about behaviours? Is it possible to describe and understand the notion of OTP behaviour in a nutshell? What 'callback function' does actually mean in the context of Elang/OTP? Can we consider the callbacks in a behaviour implemenation as methods overriden in Java? The book

How do you design the architecture of an Erlang/OTP-based distributed fault-tolerant multicore system?

倖福魔咒の 提交于 2019-12-02 13:54:32
I would like to build an Erlang/OTP-based system which solves an 'embarassingly parrallel' problem. I have already read/skimmed through: Learn You Some Erlang; Programming Erlang (Armstrong); Erlang Programming (Cesarini); Erlang/OTP in Action. I have got the gist of Processes, Messaging, Supervisors, gen_servers, Logging, etc. I do understand that certain architecture choices depend on the application in concern, but still I would like know some general principles of ERlang/OTP system design. Should I just start with a few gen_servers with a supervisor and incrementally build on that? How