Phoenix pubsub and phoenix tracker

Does anyone know of a good link or examples using phoenix pusub and phoenix tracker. I am new to Elixir but want to try and build service registry with services popping up and leaving at any time.

1 Like

I don’t have an example, but I think the rough idea would be to create a topic for your services, and subscribe all those services to this topic. Then you can use Phoenix.Presence to fetch available services. When you subscribe a service to a topic you send extra info on the service as in name or pid so it can be identified.

Having said the above, maybe you don’t need all that. Check out built-in Registry module (in Elixir >= 1.4.0). It’s simple and actually created for service registry use case, unlike Phoenix PubSub/Presence that is more of a case of pub/sub and presence has been added later which shows in the API. There’s also gproc if you need slightly more complicated querying/registration of the services.

1 link for you:

1 Like

About presence, here is the introductory video: https://dockyard.com/blog/2016/03/25/what-makes-phoenix-presence-special-sneak-peek

You can also look for @chrismccord talks at events for more information on those altogether.

3 Likes

Thank you

1 Like