Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ defmodule RealtimeWeb.RealtimeChannel.PresenceHandler do
|> Phoenix.Presence.group()
end

@presence_limit 1000
defp limit_presence_event(socket) do
%{assigns: %{presence_rate_counter: presence_counter, tenant: tenant_id}} = socket
{:ok, rate_counter} = RateCounter.get(presence_counter)

tenant = Tenants.Cache.get_tenant_by_external_id(tenant_id)
# tenant = Tenants.Cache.get_tenant_by_external_id(tenant_id)

if rate_counter.avg > tenant.max_presence_events_per_second do
if rate_counter.avg > @presence_limit do
{:error, :rate_limit_exceeded}
else
GenCounter.add(presence_counter.id)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.51.9",
version: "2.51.10",
elixir: "~> 1.17.3",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
Loading