fireproofsocks
I find it surprising that :via is not supported for duplicate registries. If you can’t register a pool of processes under the same name what exactly is the use-case for having duplicate-key registries? The docs include an example of dispatching (Registry — Elixir v1.21.0-dev), but I’m not clear how you would even put a process into a custom Registry if :via is not allowed. What am I missing? How do you actually use a custom Registry with duplicate keys?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
Registry.registerexists. You can manually (and explicitly) call it.:viais just a way to let OTP take over the process registration. But that comes with the downside that via expects a given via tuple to map to a single process, not multiple ones.derek-zhou
Process pooling is not included in the standard library of Elixir. There a few excellent libraries on hex.pm:
Some use-cases for having duplicate-key registries are explained in your linked documentation, if only you read a few more paragraphs from that point, you will find them.
al2o3cr
:viaisn’t specifically related toRegistry, it’s just a fancy way to tell:gen’s name handling to callregister_nameandwhereis_nameon a specified module:https://github.com/erlang/otp/blob/9ff030be08a162c12a13d5dfdf24f90048a24233/lib/stdlib/src/gen.erl#L622-L640
(related: Elixir’s wrappers transform a bare atom name into
{:local, name})Conversely,
Registryisn’t otherwise related to process naming - it’s just a key-value store that automatically cleans up keys when the registering process exits.The simplest thing to build with a
:duplicateregistry is a local publish-subscribe bus:{:foo, 123}useRegistry.registerto “subscribe” to that key{:foo, 123}, the sender usesRegistry.dispatchto send it to each PIDYou might even use both a
:uniqueand a:duplicateregistry with the same keys, for instance in the classic “multiplayer game” architecture::uniqueregistry tracks a GenServer per “game”. A:viatuple pointing to this registry is used when sending moves, joins, etc to the game:duplicateregistry tracks the Liveview processes of players per “game”, and is used to distribute updates to all playersfireproofsocks
Thank you for the informative responses! This is stuff that I’m going to have to ponder about for a while, but I see the set/get is pretty straightforward using
Registry.register/3andRegistry.lookup/2:What is interesting to me is that
Registry.register/3really is all about storing the current process – the value seems almost secondary. The other thing that is interesting is that when a process terminates, anything that it registered gets removed (as. you pointed out Matt):I feel like I’m only becoming dimly aware of the things that you can do with these tools…
LostKobrakai
That’s true indeed. In the end it’s a registry, so exists to hold registrations of processes. But the value can be very useful for certain usecases within the space of process registration.