I want to clean the process and free the registered name too, How would I clean that process ? as I have registered it globally {:global, String.to_atom(process_name)} ?
Agent.stop sounds the most logical. The name will be unregistered automatically, it doesnât matter if the process is stopped nicely, killed, crashed, etc.
Then click on the âagentâ link in the type definition, it will bring you to the definition of that type, which does include the :global tuple (as one of the possible values for name). So yes, it should be fine.
You can double check out that the process was unregistered by calling :global.whereis_name(process_name). This returns a pid iff the process is globally registered. You may also find Process.alive?(pid) interesting.
If you are curious, by ânaming a pidâ with a tuple like {:global, :blahname} you are saying to register it with the :global module and it is what handles monitoring, auto-unregistering, etc⊠You can make and use your own custom registration service, say named :blahglobal and use it like {:via, :blahglobal, :blahname}.
I am new to Elixir, I donât know if I will need or why I would need to have my own custom registration service, at least, I know how to register an agent and recall it now