RudolfVonKrugstein
Hi,
I am looking for a way to create a pubsub system where the publisher has a little bit more control over the subscribers:
- depending on the state of the publisher, I want to send a “welcome” message to every new subscriber, informing them about some aspects of the publisher state.
- The publisher does some heavy computing, but if there are no subscribers it shall stop. So it would be nice if it could know if any subscribers are there.
Being very new to Elixir, I am trying to figure out a good way to do this.
First I tried :pg2, but that seems to not exist anymore in OTP24.
Can Phoenix.PubSub be convinced to five me this information?
Or what can I use to replace :pg2.
Thanks for any hints ![]()
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 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
I will not comment on your bigger goal but
:pg2got replaced by:pg– so you could check that out.BradS2S
I’m pretty sure you could just use Phoenix.PubSub out of the box. Perusing the pg2 adapter module, it does check for :pg first.
Just generally speaking you could do something like:
I found this book by @sb8244 really helpful.
RudolfVonKrugstein
Oh, interessting. I have seen :pg. But bebause it is kind of unintuitive, that :pg replaced :pg2 and not the other way around, I did not think of it.
Thanks for the hint!
RudolfVonKrugstein
Thanks for the advice! The book looks very interesting, I will put it on my reading list.
The Phoenix Tracker list function I was also not aware of, that is very useful to me.
But I am also a little confused. In your example, the
:welcome_messagewould get send to any subscriber whenever any new subscriber arrives, right?Just checking,if I understand correctly.
But I could just write an explicit
subscribefunction and send an initial message to the process that just subscribed.Thanks for the help!.
BradS2S
Yes in that example it would get sent to everyone.
The convention is to have topics delimited by a colon.
So you could subscribe the user, roadrunner, to “user:acme:roadrunner” to track users by company, so you could broadcast a message to all users, all users working at acme or just roadrunner.
schneebyte
You could use pg:monitor_scope or
pg:monitor.Then you get a message whenever a process leaves or joins.
pgis very flexible, you can have multiple scopes, group names can be any term.