I'm probably missing something obvious

109 views
Skip to first unread message

Dave Thomas

unread,
Mar 14, 2017, 1:27:19 PM3/14/17
to elixir-lang-core
but the Registry module seems to require to be called by name, and not by pid. Given that, I can see a way of using it between nodes.

I wanted to replace the now-deprecated GenEvent with Registry, but this seems to be a roadblock.

As I said, I must be missing something obvious.


Dave

Michał Muskała

unread,
Mar 14, 2017, 1:36:00 PM3/14/17
to elixir-lang-core
The Registry module provides local registration. It does not provide global registration. Since a better global registry is something the OTP team is working on, there was little use in doubling the effort.

That said, you can call a named GenServer on another node using {server_name, node_name} as "reference".

Michał.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e353ee99-95b2-4471-b146-b9a7306eed3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Thomas

unread,
Mar 14, 2017, 3:13:45 PM3/14/17
to elixir-lang-core
Sure. 

So rather than remove GenEvent, could it be spun out as a Hex module? I don't really want to reinvent the wheel and write my own servers that do what it already does.


Dave

Pedro Medeiros

unread,
Mar 14, 2017, 3:24:03 PM3/14/17
to elixir-l...@googlegroups.com
Dave, you can always use the gen_event from erlang. If you you are having a more complex logic I guess that use GenStage is the way to go. As it is suggested on the master docs https://hexdocs.pm/elixir/master/GenEvent.html#content

Furthermore, I totally agree to open source GenEvent for those how can't afford to change the code right now. But with a warning that this module will no longer be maintained as it used to be.

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/18c4dd19-a65e-4a2c-a239-d8240c0b3bfb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Pedro Henrique de Souza Medeiros
----------------------------------
Cel: +55 (61) 9197-0993
Email: pedr...@gmail.com

Beautiful is better than ugly,
Explicit is better than implicit,
Simple is better than complex,
Complex is better than complicated.

The Zen of Python, by Tim Peters

Dave Thomas

unread,
Mar 14, 2017, 3:32:41 PM3/14/17
to elixir-lang-core
I read the docs. None of the suggestions is a replacement for GenEvent (apart from writing a replacement yourself). Registry, however, is. So I was assuming that GenEvent would only be deprecated if there was a replacement, and that Registry was intended to act as that. Changing the interface to registry to accept a pid as well as a name would achieve that.


Dave


On Tuesday, March 14, 2017 at 2:24:03 PM UTC-5, Pedro Medeiros wrote:
Dave, you can always use the gen_event from erlang. If you you are having a more complex logic I guess that use GenStage is the way to go. As it is suggested on the master docs https://hexdocs.pm/elixir/master/GenEvent.html#content

Furthermore, I totally agree to open source GenEvent for those how can't afford to change the code right now. But with a warning that this module will no longer be maintained as it used to be.
On Tue, Mar 14, 2017 at 4:13 PM, Dave Thomas <da...@pragdave.me> wrote:
Sure. 

So rather than remove GenEvent, could it be spun out as a Hex module? I don't really want to reinvent the wheel and write my own servers that do what it already does.


Dave


On Tuesday, March 14, 2017 at 12:36:00 PM UTC-5, Michał Muskała wrote:
The Registry module provides local registration. It does not provide global registration. Since a better global registry is something the OTP team is working on, there was little use in doubling the effort.

That said, you can call a named GenServer on another node using {server_name, node_name} as "reference".

Michał.

On 14 Mar 2017, 18:27 +0100, Dave Thomas <da...@pragdave.me>, wrote:
but the Registry module seems to require to be called by name, and not by pid. Given that, I can see a way of using it between nodes.

I wanted to replace the now-deprecated GenEvent with Registry, but this seems to be a roadblock.

As I said, I must be missing something obvious.


Dave
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e353ee99-95b2-4471-b146-b9a7306eed3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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-co...@googlegroups.com.

José Valim

unread,
Mar 14, 2017, 3:40:45 PM3/14/17
to elixir-l...@googlegroups.com
The only direct replacement for GenEvent is :gen_event.

Registry, GenStage or using supervisors require you to rethink your design and consider the trade-offs. In the Registry case, it was designed for decentralized reads so it doesn't work on PIDs. The point of registry is to not have to rely on a process.

But with :gen_event, you only need to replace "use GenEvent" by "@behaviour :gen_event" and implement the missing callbacks (which will become warnings).

And FWIW the OTP team is discussing about making callbacks optional so by the time GenEvent is actually removed from Elixir, which is still a long time ahead, migrating to :gen_event should be even more straight-forward.




José Valim
Skype: jv.ptec
Founder and Director of R&D

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/bb22503e-40fa-46da-b4ae-831fbc730e95%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages