Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Provide a way to mass update presences #145

Open
AndrewDryga opened this issue Jun 17, 2020 · 1 comment
Open

RFC: Provide a way to mass update presences #145

AndrewDryga opened this issue Jun 17, 2020 · 1 comment

Comments

@AndrewDryga
Copy link

AndrewDryga commented Jun 17, 2020

ATM if you want to update all presences for a topic you need to call Tracker.list/2 and then Tracker.update/5 for each item in the list. Tracker.update/5 implemented on top of GenServer.call/3 which would be really expensive if we going to update lots of presences at a time.

What do you feel about adding a Tracker.update_metas/3:

Tracker.update_metas(tracker_name, topic, fn _pid, _key, meta ->
  Map.put(meta, :last_updated, DateTime.utc_now()
end)
@AndrewDryga
Copy link
Author

AndrewDryga commented Jun 17, 2020

Our use case: we use Phoenix.PubSub to broadcast metrics to sockets that push data into charts in our application. To make sure that we don't pull and broadcast metrics that nobody is interested in we are using Tracker. When process subscribes for metrics we are tracking it's presence and check if anyone is subscribed for metric before pulling it from DB.

But we need to persist last event timestamp which we sent to processes so that if metrics server crashes it can recover and send remaining data while it was down. We can use presence metadata to track it but we would need to update lots of presences all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant