[erlang-questions] gproc and gen_event
Sat May 19 02:52:13 CEST 2012
gen_event is an OTP behavior for responding to events, like logging, database drivers, etc. (http://www.erlang.org/doc/design_principles/events.html). The only different part is the supervisor wants "dynamic" in the child spec (http://www.erlang.org/doc/design_principles/sup_princ.html#id71666).
gproc is a way of having centralized storage among Erlang nodes. However, if you read here http://erlang.org/pipermail/erlang-questions/2010-April/051030.html , you will discover:
"As stated before, gen_leader is a bit clumsy in environments where nodes are dynamically added and removed. Changing the participants of a gen_leader cluster is fairly difficult. The gen_leader_revival project tries to merge a number of existing modifications to gen_leader to make it more flexible." (i.e., where gen_leader is the guts behind gproc). So, if you don't have netsplits, then gproc should be fine, but I believe mnesia fits into that category as well.
pg2 is one you have ignored, which replicates process groups among the collected nodes, storing them in ETS. I chose an approach based on pg2, but without ETS in CloudI (http://cloudi.org), here: https://github.com/okeuday/CloudI/blob/master/src/lib/cloudi/src/list_pg.erl . This makes more sense with CloudI focusing on the AP part of the CAP theorem, whereas gproc is more focused on CA. I find the approach in CloudI better, since it avoids global state and that is the main point of using Erlang (with its Actor model). However, I am very biased, since I wrote it.
On 05/17/2012 05:14 PM, Andrew Berman wrote:
> I am trying to set up a pub-sub type situation where I have a function called which does some stuff and at the end broadcasts a message. I would like for multiple handlers to be able to receive that message and do something with it. I'm currently using gen_event, but have been reading about gproc as well. Can anyone explain why they'd use one over the other for pub/sub?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions