Skip to content

Commit

Permalink
✨ LONG_POLL_FALLBACK_MS
Browse files Browse the repository at this point in the history
  • Loading branch information
RTLS committed Dec 26, 2024
1 parent eb1923b commit 0ebf223
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ let csrfToken = document
.getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {
hooks: getHooks(Components),
longPollFallbackMs: parseInt(
document.querySelector("body").getAttribute("data-long-poll-fallback-ms"),
),
params: { _csrf_token: csrfToken },
});

Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ config :sequin, SequinWeb.Endpoint,
layout: false
],
pubsub_server: Sequin.PubSub,
live_view: [signing_salt: "Sm59ovfq"]
live_view: [signing_salt: "Sm59ovfq", long_poll_fallback_ms: 3000]

config :sequin, SequinWeb.UserSessionController,
github: [
Expand Down
5 changes: 4 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ if config_env() == :prod and self_hosted do
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: server_port
],
secret_key_base: secret_key_base
secret_key_base: secret_key_base,
live_view: [
long_poll_fallback_ms: String.to_integer(System.get_env("LONG_POLL_FALLBACK_MS", "3000"))
]

config :sequin, :features,
account_self_signup: account_self_signup,
Expand Down
5 changes: 5 additions & 0 deletions docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ See [secret generation](#secret-generation) for how to generate these values.
- `SEQUIN_TELEMETRY_DISABLED`: Disable telemetry data collection (default: false)
- Sequin collects telemetry data by default. While we're early, this **greatly** helps us improve the product. To opt-out, set this to `true`.

### Networking configuration

- `LONG_POLL_FALLBACK_MS`: Long poll fallback time in milliseconds (default: 3000)
- This is the duration that Sequin will wait for a healthy websocket connection before falling back to HTTP long polling. If your network configuration disallows websocket connections, you should set this to a low value (e.g. 100ms).

### Clustering configuration

You can cluster Sequin nodes in an active-passive configuration for high availability. See [Active-passive architecture](#active-passive-architecture) for more information.
Expand Down
3 changes: 3 additions & 0 deletions lib/sequin_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
Application.get_env(:sequin, :koala, [])[:public_key]
end
}
data-long-poll-fallback-ms={
Application.get_env(:sequin, SequinWeb.Endpoint)[:live_view][:long_poll_fallback_ms]
}
>
<.svelte name="components/Toaster" />
<%= if @current_user && @current_user.impersonating_user do %>
Expand Down

0 comments on commit 0ebf223

Please sign in to comment.