The gproc api

tim edited this page Aug 15, 2011 · 2 revisions

At first glance, the Gproc API may seem unwieldy.

However, most of the Gproc functionality is accessible through a few generic functions:

  • gproc:reg(Key [, Value]) for registration
  • gproc:where(Key) for name lookup
  • gproc:send(Key, Message) for message sending
  • gproc:update_counter(Key, Increment) to increment counters
  • gproc:table() for QLC queries

To use these functions, you need to understand how Gproc represents different types of data.

The structure of a key is {Type, Scope, Name}, where

  • Type is the type of resource: n (name) | p (property) | c (counter) | a (aggregated counter)
  • Scope is the registration scope: l (local) | g (global)
  • Name can be any erlang term, except the ETS wildcard symbols.

There are many other functions, but many of them are convenience functions, e.g.

gproc:register_local_name(Name) is equivalent to gproc:reg({n, l, Name}).