Hi!
I’m using Phoenix 1.0 and I count the number of subscribers on a topic by running something like this
def count_subscribers do
Enum.each Node.list, fn(node) ->
Node.spawn(node, ThingCount, :count, [self()])
end
end
...
def count do
for thing <- Repo.all(Thing), into: %{} do
{thing.id, length(Phoenix.PubSub.Local.subscribers_with_fastlanes(Thing.PubSub.Local, "thing:#{thing.id}"))}
end
end
In Phoenix 1.1 Phoenix.PubSub.Local.subscribers_with_fastlanes/2
was changed to take an additional argument, a shard.
How do I use this new API?
Do I have to call it once per shard? So, instead of iterating over Node.list I should just iterate over the number of shards? If so, how do I find out the number of shards?
I won’t need this when the presence API is released, but until then I need some way to count the active subscribers.
Any help is appreciated.