Skip to content

Commit

Permalink
Add Solid Cable adapter for ActionCable
Browse files Browse the repository at this point in the history
Switching the adapter is not expected to make any noticeable difference. The previous gem used was an interim solution and is now replaced by the new Solid Cable adapter shipping with Rails 8 by default.
  • Loading branch information
MrSerth committed Sep 30, 2024
1 parent fe87e61 commit 020b7bb
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

source 'https://rubygems.org'

gem 'actioncable-enhanced-postgresql-adapter'
gem 'bcrypt'
gem 'bootsnap', require: false
gem 'bootstrap-will_paginate'
Expand Down Expand Up @@ -47,6 +46,7 @@ gem 'rubyzip'
gem 'sassc-rails'
gem 'shakapacker', '8.0.2'
gem 'slim-rails'
gem 'solid_cable'
gem 'solid_queue'
gem 'sorcery'
gem 'sprockets-rails'
Expand Down
8 changes: 3 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ GEM
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actioncable-enhanced-postgresql-adapter (1.0.1)
actioncable (>= 6.0)
connection_pool (>= 2.2.5)
pg (~> 1.5)
actionmailbox (7.2.1)
actionpack (= 7.2.1)
activejob (= 7.2.1)
Expand Down Expand Up @@ -515,6 +511,8 @@ GEM
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
solid_cable (1.0.3)
rails (< 9)
solid_queue (0.9.0)
activejob (>= 7.1)
activerecord (>= 7.1)
Expand Down Expand Up @@ -589,7 +587,6 @@ PLATFORMS
ruby

DEPENDENCIES
actioncable-enhanced-postgresql-adapter
bcrypt
better_errors
binding_of_caller
Expand Down Expand Up @@ -662,6 +659,7 @@ DEPENDENCIES
simplecov
slim-rails
slim_lint
solid_cable
solid_queue
sorcery
sprockets-rails
Expand Down
31 changes: 19 additions & 12 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
default: &default
adapter: solid_cable # OR postgresql OR redis

### Config options for `solid_cable`
connects_to:
database:
writing: cable
polling_interval: 0.1.seconds
message_retention: 1.day
autotrim: true
silence_polling: true

### Config options for `redis`
# url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
# channel_prefix: codeocean_production

development:
adapter: enhanced_postgresql
<<: *default

test:
adapter: test

staging:
adapter: enhanced_postgresql
<<: *default

production:
adapter: enhanced_postgresql # OR postgresql OR redis

### Config options for `enhanced_postgresql`
# payload_encryptor_secret: # Required. Will be the defined value or `Rails.application.secret_key_base` or `ENV["SECRET_KEY_BASE"]`
# url: <%= ENV.fetch("DATABASE_URL") { "postgresql://localhost:5432/code_ocean_production" } %>
# connection_pool_size: <%= ENV.fetch("RAILS_MAX_THREADS", 5).to_i %> # Only used in conjunction with `url`

### Config options for `redis`
# url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
# channel_prefix: code_ocean_production
<<: *default
8 changes: 8 additions & 0 deletions config/database.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ development:
primary: &primary_development
<<: *default
database: codeocean_development
cable:
<<: *primary_development
database: codeocean_development_cable
migrations_paths: db/cable_migrate
queue:
<<: *primary_development
database: codeocean_development_queue
Expand Down Expand Up @@ -64,6 +68,10 @@ production:
primary: &primary_production
<<: *default
database: codeocean_production
cable:
<<: *primary_production
database: codeocean_production_cable
migrations_paths: db/cable_migrate
queue:
<<: *primary_production
database: codeocean_production_queue
Expand Down
25 changes: 25 additions & 0 deletions db/cable_schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions db/migrate/20240912101506_drop_action_cable_large_payloads.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class DropActionCableLargePayloads < ActiveRecord::Migration[7.2]
def change
# Drop the previously-used table for large payloads in ActionCable.
# This table was implicitly created by the EnhancedPostgresql adapter.
# Solid Cable used from now on manages the required schema separately.
drop_table :action_cable_large_payloads, if_exists: true
end
end
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 020b7bb

Please sign in to comment.