<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Andrew,<br>
<br>
gen_event is an OTP behavior for responding to events, like logging,
database drivers, etc.
(<a class="moz-txt-link-freetext" href="http://www.erlang.org/doc/design_principles/events.html">http://www.erlang.org/doc/design_principles/events.html</a>). The only
different part is the supervisor wants "dynamic" in the child spec
(<a class="moz-txt-link-freetext" href="http://www.erlang.org/doc/design_principles/sup_princ.html#id71666">http://www.erlang.org/doc/design_principles/sup_princ.html#id71666</a>).<br>
<br>
gproc is a way of having centralized storage among Erlang nodes.
However, if you read here
<a class="moz-txt-link-freetext" href="http://erlang.org/pipermail/erlang-questions/2010-April/051030.html">http://erlang.org/pipermail/erlang-questions/2010-April/051030.html</a>
, you will discover:<br>
"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.<br>
<br>
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 (<a class="moz-txt-link-freetext" href="http://cloudi.org">http://cloudi.org</a>), here:
<a class="moz-txt-link-freetext" href="https://github.com/okeuday/CloudI/blob/master/src/lib/cloudi/src/list_pg.erl">https://github.com/okeuday/CloudI/blob/master/src/lib/cloudi/src/list_pg.erl</a>
. 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.<br>
<br>
Regards,<br>
Michael<br>
<br>
On 05/17/2012 05:14 PM, Andrew Berman wrote:
<blockquote
cite="mid:CAEVpa77MUBuiCRZsL9UMboKWfPvpGO9a+K=QAu=o=LoYWQS=-Q@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
Hello,
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Andrew</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>