Registry has been updated to v0.3.0 with:
- Improved performance for 1 partition (most common case)
- Allow a process to update its own value
- Support for named listeners
- Allow metadata to be stored along-side the registry
The last two features should make the registry more extensible. Listeners allows you to give a named process when the registry is started that will receive events whenever a process registers or unregisters a key. You could use those features to add Await support to the registry or even use the registry as a pool. We have added an example of using the registry as a sojourn pool to the examples directory. The pool is an example, do not use it in production:
https://github.com/elixir-lang/registry/blob/master/examples/sojourn.exs
The pool above measures the sojourn time, which is how long messages stay in each pooled process queue. That provides an idea of how fast processes are responding. Whenever there is a dispatch, we pick two random pooled processes and choose the one with the most recent reply and smaller sojourn time.
The pool itself works by starting a worker and a registry. The worker is a listener of the registry and a supervisor guarantees that both are restarted in case any of crashes. Whenever a new process is added to the registry, the worker is notified and starts sending sampling messages to that process which updates its own entry in case of crashes.
I hope it serves as inspiration for playing with the registry for other use cases.


















