Meaning of {:via, ... }


I stumbled across this notation in Registry and I don’t remember having seen it anywhere else.

Using in :via
Once the registry is started with a given name using
Registry.start_link/1, it can be used to register and access named
processes using the {:via, Registry, {registry, key}} tuple:

I’m a returning guy from older versions of elixir and I must say I’m kind of surprised to see a tuple be “active” in some mysterious ways.

Or is it simply me being dumb and that’s only an option sent to Agent when it sees a name being a tuple beginning with :via it registers itself using the Registry ?

Thanks :slight_smile:

1 Like

The tuple isn’t active, it’s just the OTP standard format for indicating how to find a process when using any process registry other than the built in one that works on just atoms, or the built in global one that works on {:global, term} tuples.

1 Like

It has always been there.

In erlang at least.

Whenever you wanted to name a process, you were able to simply use the PID, register its name “locally” on the current node (only atoms allowed), or registering in a special module, aka using a :via-tuple. Also there are :global-tuples for registering, which in general are only erlang wide sugar around {:via, :global, ...}


Ah thanks,

Obviously I skipped some classes on erlang process name registration :wink: Thanks for the info :slight_smile:

1 Like