Groups
Groups
Sign in
Groups
Groups
elixir-lang-core
Conversations
About
Send feedback
Help
[Proposal] Create new Registry functions to allow arbitrary PID registration
52 views
Skip to first unread message
Noah Betzen
unread,
May 26, 2023, 1:39:28 PM
5/26/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elixir-lang-core
Erlang's process group module allows adding arbitrary PIDs to a group, which can be used for things like PubSub:
https://www.erlang.org/doc/man/pg.html
Registry's register function currently always registers the current process; you cannot register an arbitrary process:
https://hexdocs.pm/elixir/1.14.5/Registry.html#register/3
However, there are ways to work around this with Registry; see attached Livebook markdown for an example.
I propose new functions:
Registry.register/4
register(pid, registry, key, value)
Registry.unregister/3
unregister(pid, registry, key)
Registry.unregister_match/5
unregister_match(pid, registry, key, pattern, guards \\ [])
Registry.update_value/4
update_value(pid, registry, key, callback)
Another (potentially simpler) option might be to have the pid argument be at the end and make it default to self().
Thoughts? 😄
livemd.txt
Noah Betzen
unread,
May 26, 2023, 4:12:26 PM
5/26/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elixir-lang-core
I made a PR that implements this:
https://github.com/elixir-lang/elixir/pull/12609
Noah Betzen
unread,
May 26, 2023, 4:32:24 PM
5/26/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elixir-lang-core
Disregard, José explained that this isn't possible because of the two ETS tables that Registry uses under the hood. Oh well. 😄
Reply all
Reply to author
Forward
0 new messages