erlang

Distributed erlang security how to?

梦想的初衷 提交于 2019-12-21 04:52:12
问题 I want to have 2 independent erlang nodes that could communicate with each other: so node a@myhost will be able to send messages to b@myhost . Are there any ways to restrict node a@myhost , so only a function from a secure_module could be called on b@myhost ? It should be something like: a@myhost> rpc:call(b@myhost,secure_module,do,[A,B,C]) returns {ok,Result} and all other calls a@myhost> rpc:call(b@myhost,Modue,Func,Args) return {error, Reason} One of the options would be to use ZeroMQ

What is the best, most efficient, Client pool technique with Erlang

好久不见. 提交于 2019-12-21 04:42:23
问题 I'm a real Erlang newbie (started 1 week ago), and I'm trying to learn this language by creating a small but efficient chat server. (When I say efficient I mean I have 5 servers used to stress test this with hundreds of thousands connected client - A million would be great !) I have find some tutorials doing so, the only thing is, that every tutorial i found, are IRC like. If one user send a message, all user except sender will receive it. I would like to change that a bit, and use one-to-one

Programming language to choose for implementing distributed message passing algorithms

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 04:39:29
问题 Basically, I would want to implement the following algorithms and analyze how the system built using these algorithms behave under different conditions. Gossip protocol Multiple paxos Consistent hashing My interest here is in these algorithms. I basically am looking for a programming language that lets me write these algorithms quickly and deeply understand these algorithms. Which language should I choose? Java, Scala, Erlang or anything else. Currently, I know Java and C++. 回答1: You could

Simple example for Erlang memoization

拥有回忆 提交于 2019-12-21 04:01:04
问题 Suppose you have a simple function, which can get quite expensive for large values: fact(0) -> 1; fact(N) -> N * fact(N - 1). Where can I find a simple example of caching (or memoizing) function values by using dets ? Any other way for easy memoization would be highly appreciated. 回答1: The idea is that every time you ask for your heavy calculation, you immediately check in the cache if you've already evaluated it. If yes, you simply return the stored value. If not, you have to evaluate the

Is there an idiomatic way to order function arguments in Erlang?

旧城冷巷雨未停 提交于 2019-12-21 03:43:26
问题 Seems like it's inconsistent in the lists module. For example, split has the number as the first argument and the list as the second, but sublists has the list as the first argument and the len as the second argument. 回答1: OK, a little history as I remember it and some principles behind my style. As Christian has said the libraries evolved and tended to get the argument order and feel from the impulses we were getting just then. So for example the reason why element/setelement have the

Is there an idiomatic way to order function arguments in Erlang?

那年仲夏 提交于 2019-12-21 03:43:08
问题 Seems like it's inconsistent in the lists module. For example, split has the number as the first argument and the list as the second, but sublists has the list as the first argument and the len as the second argument. 回答1: OK, a little history as I remember it and some principles behind my style. As Christian has said the libraries evolved and tended to get the argument order and feel from the impulses we were getting just then. So for example the reason why element/setelement have the

Finite State Machine and inter-FSM signaling

我与影子孤独终老i 提交于 2019-12-21 03:36:44
问题 Recommendations for languages with native (so no FSM generation tools) support for state machine development and execution and passing of messages/signals. This is for telecoms, e.g implementation of FSMs of this level of complexity. I have considered Erlang, but would love some feedback, suggestions, pointer to tutorials, alternatives, particularly Java based frameworks. Maybe Scala? Open source only. I'm not looking for UML or regular expression related solutions. As this is for the

Why is -compile(export_all) bad practice?

僤鯓⒐⒋嵵緔 提交于 2019-12-21 03:28:13
问题 All the erlang books seem to say export_all is bad practice but don't give a reason. In the end most modules spend a majority of their time with compile(export_all) because constantly updating the list of modules to remove the helper functions is a hassle. Is it bad practice because I'm supposed to care about the functions I expose to other developers? Or is it bad practice because there's some kind of performance cost in the number of functions a module has, because of maybe things like hot

How should Erlang deal with common data

为君一笑 提交于 2019-12-21 02:53:27
问题 (I have almost no experience with Erlang, just read some books) Suppose that I'm building game server using Erlang. It's very common circulation each user to check something(eg, finding the closest player), so there's a manager class for that usually. In above case, we use mutex lock. As I know Erlang create new Erlang-process per each TCP connection(user session) normally. Then, how the list of user session can be circulated? If I have parent process for those user sessions and ask to parent

Getting the time of the received message

删除回忆录丶 提交于 2019-12-21 02:52:08
问题 How does one get the time of the received message in Erlang? I want to calculate something according to the frequency of the received messages to the gen_server. e.g. message 1, some time, message 2 some time. get the time between messages. Thanks 回答1: You can use statistics(wall_clock) each time you receive a message. The second member of the tuple it returns will be the time between the two receives (in milliseconds). Edit : As rvirding mentions in his comment, you can also use now() and