Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoprietog committed Jan 2, 2024
1 parent 569afc3 commit 3232ed3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
10 changes: 2 additions & 8 deletions actioncable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
* Compress large payloads in all subscription adapters
* Compress large payloads in all subscription adapters with ActiveSupport::Gzip

This allows to broadcast payloads larger than 8000 bytes by compressing them with ActiveSupport::Gzip with PostgreSQL

```yaml
production:
adapter: postgresql
channel_prefix: appname_production
```
This will also help broadcast payloads on average 2 to 3 times larger on adapters such as PostgreSQL that has a size limit

*Bruno Prieto*

Expand Down
3 changes: 1 addition & 2 deletions actioncable/lib/action_cable/subscription_adapter/inline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def initialize(*)
end

def broadcast(channel, payload)
payload = @compressor.compress(payload)
subscriber_map.broadcast(channel, payload)
subscriber_map.broadcast(channel, @compressor.compress(payload))
end

def subscribe(channel, callback, success_callback = nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PostgreSQL < Base # :nodoc:
def initialize(*)
super
@listener = nil
@compressor = Compressor.new(threshold: 7.8.kilobytes, compressor: ActiveSupport::Gzip)
@compressor = Compressor.new
end

def broadcast(channel, payload)
Expand Down
3 changes: 1 addition & 2 deletions actioncable/lib/action_cable/subscription_adapter/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def initialize(*)
end

def broadcast(channel, payload)
payload = @compressor.compress(payload)
redis_connection_for_broadcasts.publish(channel, payload)
redis_connection_for_broadcasts.publish(channel, @compressor.compress(payload))
end

def subscribe(channel, callback, success_callback = nil)
Expand Down

0 comments on commit 3232ed3

Please sign in to comment.