Skip to content

Commit

Permalink
chore: Set up solid cable
Browse files Browse the repository at this point in the history
  • Loading branch information
mromulus committed Nov 13, 2024
1 parent 39de40f commit e0dfe8c
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 25 deletions.
29 changes: 16 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# core
gem 'bootsnap', '>= 1.4.2', require: false
gem 'haml-rails', '~> 2.0'
gem 'rgl'
gem 'rails', '~> 8.0.0'
gem 'pg'
gem 'sqlite3'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'puma'
gem 'nilify_blanks', '~> 1.4'
gem 'rails', '~> 8.0.0'
gem 'oj', '~> 3.10'
gem 'pry-rails', '~> 0.3.9'
gem 'rails-patterns'
gem 'friendly_id', '~> 5.5.0'
gem 'view_component'
gem 'jwt'
gem 'http', '~> 5.0'
gem 'nilify_blanks', '~> 1.4'
gem 'solid_cable'

# frontend
gem 'haml-rails', '~> 2.0'
gem 'turbo-rails', '~> 2.0'
gem 'liquid', '~> 5.5'
gem 'view_component'

# TO BE REMOVED
gem 'redis'
gem 'hiredis', '~> 0.6.3'
gem 'mail', '~> 2.8'
gem 'nokogiri', '~> 1.16'
gem 'stringex', '~> 2.8', require: 'stringex_lite'

# functionality
gem 'stringex', '~> 2.8', require: 'stringex_lite'
gem 'http', '~> 5.0'
gem 'liquid', '~> 5.5'
gem 'rgl'
gem 'acts-as-taggable-on', '~> 12.0'
gem 'ipaddress', github: 'ipaddress-gem/ipaddress'
gem 'simple_form', '~> 5.3'
Expand Down Expand Up @@ -80,4 +82,5 @@ group :development do

gem 'silencer'
gem 'awesome_print', '~> 1.9'
gem 'pry-rails', '~> 0.3.9'
end
14 changes: 9 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ GEM
bindata
faraday (~> 2.0)
faraday-follow_redirects
jwt (2.9.3)
base64
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand Down Expand Up @@ -460,6 +458,13 @@ GEM
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
solid_cable (3.0.2)
actioncable (>= 7.2)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
sqlite3 (2.2.0-x86_64-linux-gnu)
sqlite3 (2.2.0-x86_64-linux-musl)
stackprof (0.2.26)
stream (0.5.5)
stringex (2.8.6)
Expand Down Expand Up @@ -544,15 +549,12 @@ DEPENDENCIES
hiredis (~> 0.6.3)
http (~> 5.0)
ipaddress!
jwt
kaminari
liquid (~> 5.5)
listen
mail (~> 2.8)
memory_profiler
naturally (~> 2.2)
nilify_blanks (~> 1.4)
nokogiri (~> 1.16)
oj (~> 3.10)
omniauth (~> 2.0)
omniauth-rails_csrf_protection
Expand All @@ -576,6 +578,8 @@ DEPENDENCIES
sentry-ruby
silencer
simple_form (~> 5.3)
solid_cable
sqlite3
stackprof
stringex (~> 2.8)
turbo-rails (~> 2.0)
Expand Down
18 changes: 12 additions & 6 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
development:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: providentia_development
adapter: solid_cable
connects_to:
database:
writing: cable
polling_interval: 0.1.seconds
message_retention: 1.day

test:
adapter: test

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: providentia_production
adapter: solid_cable
connects_to:
database:
writing: cable
polling_interval: 0.1.seconds
message_retention: 1.day
48 changes: 47 additions & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
default_pg: &default_pg
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

default_sqlite: &default_sqlite
adapter: sqlite3
pool: 5
timeout: 5000

development:
primary:
<<: *default_pg
url: <%= ENV["DATABASE_URL"] %>
cache:
<<: *default_sqlite
database: storage/development_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default_sqlite
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default_sqlite
database: storage/development_cable.sqlite3
migrations_paths: db/cable_migrate

# only specify one for test
test:
url: "postgres://providentia:secret@postgresql/providentia_test?pool=5"
primary:
url: "postgres://providentia:secret@postgresql/providentia_test?pool=5"

production:
primary:
<<: *default_pg
url: <%= ENV["DATABASE_URL"] %>
cache:
<<: *default_sqlite
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default_sqlite
database: storage/production_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default_sqlite
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
25 changes: 25 additions & 0 deletions db/cable_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 1) do
create_table 'solid_cable_messages', force: :cascade do |t|
t.binary 'channel', limit: 1024, null: false
t.binary 'payload', limit: 536870912, null: false
t.datetime 'created_at', null: false
t.integer 'channel_hash', limit: 8, null: false
t.index ['channel'], name: 'index_solid_cable_messages_on_channel'
t.index ['channel_hash'], name: 'index_solid_cable_messages_on_channel_hash'
t.index ['created_at'], name: 'index_solid_cable_messages_on_created_at'
end
end

0 comments on commit e0dfe8c

Please sign in to comment.