[erlang-questions] Confusing about gproc with global properties

Ulf Wiger ulf.wiger@REDACTED
Fri Apr 15 23:25:19 CEST 2011


Hi Greg,

Yeah, gproc:select/1 is a bit confusing.

It is actually equivalent to gproc:select(all, Pat), where the first argument is the type (names, properties, etc.) - not the scope.

Not that you'd know this from reading the docs, but you can do this:

(n1@REDACTED)21> gproc:select({global,all},[{'_',[],['$$']}]).      
[[{p,g,foo},<0.37.0>,bar]]
(n1@REDACTED)22> gproc:select({local,all},[{'_',[],['$$']}]). 
[[{p,l,foo},<0.37.0>,bar]]
(n1@REDACTED)23> gproc:select({all,all},[{'_',[],['$$']}]).  
[[{p,g,foo},<0.37.0>,bar],[{p,l,foo},<0.37.0>,bar]]

The {Scope, Type} tuple is, I think wholly undocumented.

I'll go over the type specs and the documentation on that one. Thanks for highlighting it.

BR,
Ulf W

On 15 Apr 2011, at 20:24, Gregory Haskins wrote:

> Hi Ulf, all,
> 
> I am playing around with adding gproc to my edist framework.  I plan on
> using it for both a pubsub fabric as well as for end-point management.
> I ran into a snag during the integration that I _swear_ worked when I
> did some small proof-of-concept work with gproc as stand alone.
> 
> That is, it seems any global properties that are registered never end up
> showing up.  Consider this:
> 
> (controller@REDACTED)2> gproc:reg({p, l, foo}, bar).
> true
> (controller@REDACTED)3> gproc:reg({p, g, foo}, bar).
> true
> (controller@REDACTED)4>
> (controller@REDACTED)4>
> (controller@REDACTED)4> gproc:select([{'_', [], ['$$']}]).
> [[{p,l,foo},<0.131.0>,bar]]
> 
> I do not understand why it appears that all global registrations meet a
> /dev/null fate.  Any pointers are greatly appreciated.
> 
> Note that if I trace gproc_dist, I can see activity during the {p, g, _}
> registration, as you would expect.  I started erl with "-gproc
> gproc_dist 'all'".  I am using the v0.1.2 branch of esl/gproc
> (https://github.com/esl/gproc/tree/v0.1.2), which, IIUC, is the tree Ulf
> recommends we use (though now I cannot seem to remember where I got that
> impression).
> 
> Kind Regards,
> -Greg
> 
> 

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com






More information about the erlang-questions mailing list