Registry Processes
Learn the registry processes, including how to name them, the types of naming techniques, and how to start them.
We'll cover the following...
Name processes using the Registry
Until now, we used the process identifier obtained from starting the process to interact with it. However, we can optionally provide a :name
value when starting a process. This can be used later instead of a PID. This way, we don’t have to keep track of the PIDs of the processes we start. Functions like GenServer.cast/2
and GenServer.call/3
also accept a name instead of a process identifier, and we’ve already seen how to use Process.whereis/1
to find out the PID for JobRunner
.
To make working with names easier, Elixir comes with a module called Registry
. It’s an efficient ...