derekkraan / horde

Horde is a distributed Supervisor and Registry backed by DeltaCrdt
MIT License
1.32k stars 106 forks source link

Use PG2 as default cluster formation #171

Closed shikanime closed 5 years ago

shikanime commented 5 years ago

It would be more convenient to create a cluster of DynamicSupervisor / Registry using PG2 by default such as Phoenix.Pubsub.

derekkraan commented 5 years ago

Can you elaborate?

shikanime commented 5 years ago

Actually every Horde components are discovered statically via Erlang node name:

{HelloWorld.HelloDynamicSupervisor, :"count1@127.0.0.1"}

In the case of a dynamic cluster such as under a container orchestrator like Kubernetes, we have to monitor the node to join or leave and ensure proper synchronization of the Horde cluster on the user space can be sometime less convenient.

Instead the component should join the pg2 {:horde, name} group at startup where name can be HelloWorld.HelloDynamicSupervisor.

In comparaison Phoenix.PubSub is using {:phx, name} to discover every of his node on the Erlang cluster.

What do you think? Can there be any issues?

derekkraan commented 5 years ago

I think I would rather leave this up to the person who is using Horde. If you would like to submit a PR documenting how to get Horde working with pg2, then I would accept that.