Skip to content

Commit

Permalink
Replace Redis with Solid Queue
Browse files Browse the repository at this point in the history
  • Loading branch information
northeastprince committed Jan 10, 2025
1 parent 796175f commit da4acf5
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 25 deletions.
1 change: 0 additions & 1 deletion .env.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
RAILS_MASTER_KEY=<%= ENV["RAILS_MASTER_KEY"] %>
REDIS_URL=<%= ENV["REDIS_URL"] %>

<% ENV["RAILS_ENV"] = "production" %>
<% require_relative "config/application" %>
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ jobs:
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- uses: crazy-max/ghaction-github-runtime@v3
- name: Get credentials from Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
curl https://cli-assets.heroku.com/install-ubuntu.sh | sudo sh
REDIS_URL=$(heroku config:get REDIS_URL -a hackathons)
echo "REDIS_URL=${REDIS_URL}" >> $GITHUB_ENV
- name: Deploy to production!
run: bundle exec kamal deploy
env:
Expand Down
2 changes: 0 additions & 2 deletions .kamal/secrets
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD

RAILS_MASTER_KEY=$RAILS_MASTER_KEY

REDIS_URL=$REDIS_URL

LITESTREAM_ACCESS_KEY_ID=$LITESTREAM_ACCESS_KEY_ID
LITESTREAM_SECRET_ACCESS_KEY=$LITESTREAM_SECRET_ACCESS_KEY
LITESTREAM_BUCKET=$LITESTREAM_BUCKET
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ gem "dotenv-rails", require: "dotenv/load"
# Drivers
gem "sqlite3"
gem "puma"
gem "redis"

gem "solid_cable"

# Assets
gem "sprockets-rails"
Expand Down
11 changes: 6 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,6 @@ GEM
rake (13.2.1)
rdoc (6.10.0)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
regexp_parser (2.10.0)
reline (0.6.0)
io-console (~> 0.5)
Expand Down Expand Up @@ -417,6 +413,11 @@ GEM
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
solid_cable (3.0.5)
actioncable (>= 7.2)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_queue (1.1.2)
activejob (>= 7.1)
activerecord (>= 7.1)
Expand Down Expand Up @@ -530,8 +531,8 @@ DEPENDENCIES
rack-cors
rack-mini-profiler
rails!
redis
simple_form
solid_cable
solid_queue
sprockets-rails
sqlite3
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ brew install vips

**Vendors:**

- Heroku
- Redis (Heroku Data for Redis `premium0`)
- Hetzner
- Runs the Rails app and Solid Queue (3 vCPU, 4 GB)
- Deployed via [Kamal](https://kamal-deploy.org)
Expand Down
8 changes: 4 additions & 4 deletions config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test:
adapter: test

production:
adapter: redis
url: <%= ENV["REDIS_URL"] %>
ssl_params:
verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
adapter: solid_cable
connects_to:
database:
writing: cable
9 changes: 7 additions & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ test:
database: storage/test.sqlite3

production:
<<: *default
database: storage/production.sqlite3
primary:
<<: *default
database: storage/production.sqlite3
cable:
<<: *default
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
1 change: 0 additions & 1 deletion config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ env:
WEB_CONCURRENCY: 2
secret:
- RAILS_MASTER_KEY
- REDIS_URL

asset_path: "/hackathons/public/assets"
volumes: ["hackathons-storage:/hackathons/storage"]
Expand Down
11 changes: 11 additions & 0 deletions db/cable_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ActiveRecord::Schema[7.1].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 da4acf5

Please sign in to comment.