Browse Source

expose socket constants (#5022)

* expose socket constants

* remove polling from config name
Khaleel Al-Adhami 1 tháng trước cách đây
mục cha
commit
553da33b7a
2 tập tin đã thay đổi với 14 bổ sung3 xóa
  1. 3 3
      reflex/app.py
  2. 11 0
      reflex/config.py

+ 3 - 3
reflex/app.py

@@ -498,9 +498,9 @@ class App(MiddlewareMixin, LifespanMixin):
                     else config.cors_allowed_origins
                 ),
                 cors_credentials=True,
-                max_http_buffer_size=constants.POLLING_MAX_HTTP_BUFFER_SIZE,
-                ping_interval=constants.Ping.INTERVAL,
-                ping_timeout=constants.Ping.TIMEOUT,
+                max_http_buffer_size=environment.REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE.get(),
+                ping_interval=environment.REFLEX_SOCKET_INTERVAL.get(),
+                ping_timeout=environment.REFLEX_SOCKET_TIMEOUT.get(),
                 json=SimpleNamespace(
                     dumps=staticmethod(format.json_dumps),
                     loads=staticmethod(json.loads),

+ 11 - 0
reflex/config.py

@@ -723,6 +723,17 @@ class EnvironmentVariables:
     # The address to bind the HTTP client to. You can set this to "::" to enable IPv6.
     REFLEX_HTTP_CLIENT_BIND_ADDRESS: EnvVar[str | None] = env_var(None)
 
+    # Maximum size of the message in the websocket server in bytes.
+    REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE: EnvVar[int] = env_var(
+        constants.POLLING_MAX_HTTP_BUFFER_SIZE
+    )
+
+    # The interval to send a ping to the websocket server in seconds.
+    REFLEX_SOCKET_INTERVAL: EnvVar[int] = env_var(constants.Ping.INTERVAL)
+
+    # The timeout to wait for a pong from the websocket server in seconds.
+    REFLEX_SOCKET_TIMEOUT: EnvVar[int] = env_var(constants.Ping.TIMEOUT)
+
 
 environment = EnvironmentVariables()