otp

Concurrency: Processes vs Threads

若如初见. 提交于 2019-12-21 06:59:45
问题 What are the main advantages of using a model for concurrency based on processes over one based on threads and in what contexts is the latter appropriate? 回答1: Fault-tolerance and scalability are the main advantages of using Processes vs. Threads. A system that relies on shared memory or some other kind of technology that is only available when using threads, will be useless when you want to run the system on multiple machines. Sooner or later you will need to communicate between different

Access project version within elixir application

自古美人都是妖i 提交于 2019-12-21 03:18:22
问题 I have an elixir project with a defined version. How can I access this from within the running application. in mix.exs def project do [app: :my_app, version: "0.0.1"] end I would like to be access this version number in the application so I can add it to the returned message. I looking for something in the env hash like the following __ENV__.version # => 0.0.1 回答1: Here's a similar approach to retrieve the version string. It also relies on the :application module, but is maybe a bit more

Erlang/OTP architecture: RESTful protocol for SOAish services

痴心易碎 提交于 2019-12-21 01:22:33
问题 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

Erlang/OTP architecture: RESTful protocol for SOAish services

左心房为你撑大大i 提交于 2019-12-21 01:22:16
问题 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

Erlang: Distributed Application Strange behaviour

Deadly 提交于 2019-12-18 13:21:12
问题 I'm paying with distributed erlang applications. Configuration and ideas are taken from: http:/www.erlang.org/doc/pdf/otp-system-documentation.pdf 9.9. Distributed Applications We have 3 nodes: n1@a2-X201, n2@a2-X201, n3@a2-X201 We have application wd that do some useful job :) Configuration files: wd1.config - for the first node: [{kernel, [{distributed,[{wd,5000,['n1@a2-X201',{'n2@a2-X201','n3@a2-X201'}]}]}, {sync_nodes_mandatory,['n2@a2-X201','n3@a2-X201']}, {sync_nodes_timeout,5000} ]} ,

Are there things Elixir can do that Erlang cannot, or vice versa?

為{幸葍}努か 提交于 2019-12-18 09:58:53
问题 This question is in the context of the Beam VM and the capabilities that it provides, not in the general context of what a Turing complete language can do. I want to invest some time to learn either pure Erlang or Elixir. I get the basic differences between the two and I am leaning towards Elixir because of the macros, better syntax and faster development of the language this day. My question is: if I choose Elixir, will I stumble on something that I cannot do in it, but can do in Erlang? Can

How to connect to a registered Node (Erlang) and use it from Ejabberd

主宰稳场 提交于 2019-12-13 17:14:59
问题 I have a server application with a running node, awaits for rpc calls.... (n2@198.XXX.X.XX)> I have a node started on a different machine in which I have ejabberd running as well erl -name n2@198.XXX.X.XX -setcookie somecookie (n1@198.XXX.X.XX)> And then I have ejabberd server started with ejabberdctl live and I want to be able to ping n2 from n1 (n1@198.XXX.X.XX)>. I can see that n1 is registered and running with net_adm:names(). I tried to do do directly from code net_adm:ping(n2@198.XXX.X

Mochiweb: Include and compile other libraries

北城余情 提交于 2019-12-13 08:32:20
问题 My app uses Mochiweb. I have noticed that Mochiweb files reside in the myapp/deps/mochiweb directory and rebar compiles them when I run make in the myapp directory. I wanted to add ibrowse to write a few tests which make http requests to my app. So I cloned ibrowse from github to myapp/deps/ibrowse directory. But it seems that Erlang does not know where to get the .beam files for ibrowse and therefore all my tests that use the ibrowse module fail: myapp ebin %%compiled tests reside here,

Can I use an existing OTP application inside another application or module?

扶醉桌前 提交于 2019-12-12 19:56:26
问题 I'm building a system that needs to use a previously built OTP application (lets call it X). If I want to build a new OTP application / module, how can I use the application that already exists from a module, for instance? I assumed I could call start , since it follows the application behaviour, and so I built a minimalistic application Y that has the following code: y.erl: -module(y). -behaviour(application). start(_StartType, _StartArgs) -> io:format("going to call x_app~n"), {ok, _} = x

Where should you put application properties in a rebar erlang application?

倖福魔咒の 提交于 2019-12-12 11:23:42
问题 A newbie question: I wrote my first rebar based erlang application. I want to configure some basic properites like server host etc. Where is the best place to put them and how should I load them into the app? 回答1: The next steps are to make a release and create a node in it. A node runs your application in a standalone Erlang VM. A good starting point for creating a release using rebar: Erlang Application Management with Rebar Once you have created a release. The configuration properties for