July 2021
Intermediate to advanced
176 pages
4h 14m
English
Until now, we used the process identifier we obtained from starting the process to interact with it. However, we can optionally provide a :name value when starting a process, which can be used later on instead of a PID. This way you don’t have to keep track of the PIDs of the processes you’re starting. Functions like GenServer.cast/2 and GenServer.call/3 also accept a name instead of a process identifier, and you’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 is a very efficient key-value store with some useful functionality. Let’s see how we can use it.
Processes can be named when they start ...
Read now
Unlock full access