The new `Registry.select/2` and what match specs are
The Elixir 1.9 changelog includes a new function for registries, reasonably overshadowed by the new release task and better config handling. I want to tell you a bit about
Registry.select/2, what it does, and why it’s exciting. This will also include a very brief introduction to how Erlang match specs work.
Backstory and my experience contributing to Elixir #
A while ago I was working on a project where I needed to dynamically start and stop workers polling some third-party service. This was a straightforward setup of GenServer workers, a DynamicSupervisor to keep them, a Registry to look up existing workers, and finally, a coordinating GenServer that starts and stops workers (let’s call it Coordinator). The canonical truth of what workers should be active was in a Postgres database, so periodically the Coordinator would get the latest list of active services. It would then diff that...
Continue reading →