Registry has been updated to v0.3.0 with:

  1. Improved performance for 1 partition (most common case)
  2. Allow a process to update its own value
  3. Support for named listeners
  4. 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.

*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LN_CU6w%2BCgMrbr1%2Be4r%3DktHqONOS%2Bik5XR6BG2zjWBBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to