-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
fix: Allow Overriding of max_channels_per_client
via Environment Variable
#866
base: main
Are you sure you want to change the base?
Conversation
@barrownicholas is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
@filipecabaco when you have time could you take a peak at this? You've been a huge help in the past, sorry to bother, you're just the best point-of-contact I have!! |
max_channels_per_client
via Environment Variablemax_channels_per_client
via Environment Variable
@@ -388,7 +388,7 @@ defmodule RealtimeWeb.RealtimeChannel do | |||
def limit_channels(%{assigns: %{tenant: tenant, limits: limits}, transport_pid: pid}) do | |||
key = Tenants.channels_per_client_key(tenant) | |||
|
|||
if Registry.count_match(Realtime.Registry, key, pid) > limits.max_channels_per_client do | |||
if Registry.count_match(Realtime.Registry, key, pid) > String.to_integer(System.get_env("MAX_CHANNELS_PER_CLIENT") || Integer.to_string(limits.max_channels_per_client)) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this first checks (for existing tenants) if MAX_CHANNELS_PER_CLIENT
and uses that value (or defaults back to the limit existing on the tenant) for backwards compatibility. Both are treated as strings to allow comparison, before finally being converted back to an integer for use/processing.
@@ -18,6 +18,7 @@ Repo.transaction(fn -> | |||
"external_id" => tenant_name, | |||
"jwt_secret" => | |||
System.get_env("API_JWT_SECRET", "super-secret-jwt-token-with-at-least-32-characters-long"), | |||
"max_channels_per_client" => String.to_integer(System.get_env("MAX_CHANNELS_PER_CLIENT") || "100"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always use the new value on new clients, default back to system default of 100
Also, can confirm that this built successfully in Docker on my local machine |
👋 will check today sorry for the delay |
What kind of change does this PR introduce?
Bug fix: allows overriding the default of
100
formax_channels_per_client
on a realtime tenant.What is the current behavior?
The default is locked at 100 without any ready way to override it.
What is the new behavior?
Allows a user to specify
MAX_CHANNELS_PER_CLIENT
in the runtime environment to override this value.Additional context
Fixes #843