Is it possible to use both genstage and genserver in the same module? Wouldn’t their callbacks clash?
defmodule Test do
use GenServer
use GenStage
...
end
Right now I have a genserver whose role is to control two ets tables. It did’t have any state, so I thought I would collect the updates to these tables in this genserver’s state so that it can be a producer for genstage.
The original problem is that I have a leaderboard which I want to slightly “decouple” from the web part of the app (phoenix). Both web and leaderboard are apps
under umbrella. But I also want to be able to send updates through channels whenever the leaderboard changes.
My first attempt at solving this was to make Test.Endpoint.broadcast/3
calls from inside the leaderboard module, but that didn’t work for me because in this case the leaderboard was dependent on the web part, and i wanted it the other way around because I think it makes more sense. Also whenever someone joins the channel they get the current state of the leaderboard in response.
Now i’m trying to use genstage but i’m afraid it’s overkill for my problem.