Repository navigation
feat: broadcast persistence opt-in - #2235
Conversation
CRAP Score Report |
1290865 to
885a454
Compare
a2fcb86 to
bc27e16
Compare
| @typedoc """ | ||
| What the sender asked for, once parsed. `nil` means they did not ask to save the message. | ||
| """ | ||
| @type persist :: %{ttl: pos_integer()} | nil |
There was a problem hiding this comment.
ttl is pretty much the standard name used everywhere so I reused the same name because it's already familiar.
bc27e16 to
2921b8c
Compare
2921b8c to
bf3c596
Compare
f2e3081 to
9347579
Compare
GoTrue's add_auth_jwt_function migration replaces auth.jwt(), which fails with 'must be owner of function jwt' when the init script created it as supabase_admin. The e2e stack runs GoTrue against this database since #2369.
9347579 to
90b32f2
Compare
This comment has been minimized.
This comment has been minimized.
|
Just a heads up, the |
# Conflicts: # lib/realtime_web/channels/realtime_channel/broadcast_handler.ex # test/realtime_web/channels/realtime_channel/broadcast_handler_test.exs
|
Hey @mandar1045 noted and thanks for that one as well! We'll follow up with #2390 as soon as possible 🙏🏻 |
|
|
||
| def up do | ||
| execute """ | ||
| CREATE INDEX IF NOT EXISTS messages_replay_index ON realtime.messages |
There was a problem hiding this comment.
I wonder if we should create index concurrently ? I don't have a strong preference tbh as each partition will have a separate index etc. Just thought I would bring the question.
There was a problem hiding this comment.
create index concurrently on the partitioned realtime.messages is not supported, the alternative is creating the index on each one separated but I don't think it's worth it.
# Conflicts: # lib/realtime/tenants/authorization.ex # lib/realtime/tenants/migrations.ex # priv/repo/tenant_db_dump_15.sql # priv/repo/tenant_db_dump_17.sql
This comment has been minimized.
This comment has been minimized.
# Conflicts: # lib/realtime/tenants/migrations.ex
|
🎉 This PR is included in version 2.150.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Broadcast Persistence Opt-in (enable/disable)
The parameter
Either a boolean to enable using default values or a map to overwrite the ttl. Usually I don't like two different data types for the same parameter but the alternative would be
persist: {}to enable using defaults which reads worse thanpersist: true.persistpersist: truepersist: { ttl: 3600 }Note: stored only if the policy allows, obviously.
TTL
Users can pass a positive integer from 1 to 259200 (72 hours) to define how long the message can be replayed. Invalid and out of bounds values are rejected.
The ttl is stored as
expires_atand filtered at runtime, the row is deleted along with the partition after 72h independently of theexpires_atvalue.Notes:
ttlfor now and just doenable: truewith max expiration. Either way we can seettlis a good fit and works.One probe instead of two (bench)
Persistence needs a second
:persistenceRLS check on top of:broadcast. Run both in one call to save resources:Note that WS caches that probe in the channel, but HTTP has no caching so it must run on every request.
See
bench/authorization_probe.exsReplay
We need to increase the replay limit, currently set at
@hard_limit 25, but it's out of scope, to be done in a follow-up PR.Clients
Supabase-JS requires supabase/supabase-js#2690 to accept the
:persistmetadata. Other clients requires similar or more work to support Persistence.