Skip to content

Commit 9716ab7

Browse files
committed
Use solid gems
1 parent 75e933e commit 9716ab7

File tree

13 files changed

+268
-21
lines changed

13 files changed

+268
-21
lines changed

Gemfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ gem "stimulus-rails"
1818
gem "tailwindcss-rails"
1919
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2020
gem "jbuilder"
21-
# Use Redis adapter to run Action Cable in production
22-
gem "redis", ">= 4.0.1"
23-
24-
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
25-
# gem "kredis"
2621

2722
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
2823
gem "bcrypt", "~> 3.1.7"
2924

3025
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
3126
gem "tzinfo-data", platforms: %i[ windows jruby ]
3227

28+
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
29+
gem "solid_cache"
30+
gem "solid_queue"
31+
gem "solid_cable"
32+
3333
# Reduces boot times through caching; required in config/boot.rb
3434
gem "bootsnap", require: false
3535

Gemfile.lock

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ GEM
106106
drb (2.2.3)
107107
erb (5.0.2)
108108
erubi (1.13.1)
109+
et-orbi (1.4.0)
110+
tzinfo
111+
fugit (1.11.2)
112+
et-orbi (~> 1, >= 1.2.11)
113+
raabro (~> 1.4)
109114
globalid (1.2.1)
110115
activesupport (>= 6.1)
111116
honeybadger (6.1.0)
@@ -194,6 +199,7 @@ GEM
194199
public_suffix (6.0.2)
195200
puma (7.0.3)
196201
nio4r (~> 2.0)
202+
raabro (1.4.0)
197203
racc (1.8.1)
198204
rack (3.2.1)
199205
rack-session (2.1.1)
@@ -238,10 +244,6 @@ GEM
238244
erb
239245
psych (>= 4.0.0)
240246
redcarpet (3.6.1)
241-
redis (5.3.0)
242-
redis-client (>= 0.22.0)
243-
redis-client (0.22.2)
244-
connection_pool
245247
regexp_parser (2.11.3)
246248
reline (0.6.2)
247249
io-console (~> 0.5)
@@ -284,6 +286,22 @@ GEM
284286
rexml (~> 3.2, >= 3.2.5)
285287
rubyzip (>= 1.2.2, < 4.0)
286288
websocket (~> 1.0)
289+
solid_cable (3.0.4)
290+
actioncable (>= 7.2)
291+
activejob (>= 7.2)
292+
activerecord (>= 7.2)
293+
railties (>= 7.2)
294+
solid_cache (1.0.6)
295+
activejob (>= 7.2)
296+
activerecord (>= 7.2)
297+
railties (>= 7.2)
298+
solid_queue (1.2.1)
299+
activejob (>= 7.1)
300+
activerecord (>= 7.1)
301+
concurrent-ruby (>= 1.3.1)
302+
fugit (~> 1.11.0)
303+
railties (>= 7.1)
304+
thor (>= 1.3.1)
287305
stimulus-rails (1.3.4)
288306
railties (>= 6.0.0)
289307
stringio (3.1.7)
@@ -345,9 +363,11 @@ DEPENDENCIES
345363
propshaft
346364
puma (>= 5.0)
347365
rails (~> 8.0.2.1)
348-
redis (>= 4.0.1)
349366
rubocop-rails-omakase
350367
selenium-webdriver
368+
solid_cable
369+
solid_cache
370+
solid_queue
351371
stimulus-rails
352372
tailwindcss-rails
353373
turbo-rails

bin/jobs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
3+
require_relative "../config/environment"
4+
require "solid_queue/cli"
5+
6+
SolidQueue::Cli.start(ARGV)

config/cable.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
# Async adapter only works within the same process, so for manually triggering cable updates from a console,
2+
# and seeing results in the browser, you must do so from the web console (running inside the dev process),
3+
# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
4+
# to make the web console appear.
15
development:
2-
adapter: redis
3-
url: redis://localhost:6379/1
6+
adapter: async
47

58
test:
69
adapter: test
710

811
production:
9-
adapter: redis
10-
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
11-
channel_prefix: jbakerdev_production
12+
adapter: solid_cable
13+
connects_to:
14+
database:
15+
writing: cable
16+
polling_interval: 0.1.seconds
17+
message_retention: 1.day

config/cache.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
default: &default
2+
store_options:
3+
# Cap age of oldest cache entry to fulfill retention policies
4+
# max_age: <%= 60.days.to_i %>
5+
max_size: <%= 256.megabytes %>
6+
namespace: <%= Rails.env %>
7+
8+
development:
9+
<<: *default
10+
11+
test:
12+
<<: *default
13+
14+
production:
15+
database: cache
16+
<<: *default

config/database.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,20 @@ test:
7979
# for a full overview on how database connection configuration can be specified.
8080
#
8181
production:
82-
<<: *default
83-
database: jbakerdev_production
84-
username: jbakerdev
85-
password: <%= ENV["JBAKERDEV_DATABASE_PASSWORD"] %>
82+
primary: &primary_production
83+
<<: *default
84+
database: jbakerdev_production
85+
username: jbakerdev
86+
password: <%= ENV["JBAKERDEV_DATABASE_PASSWORD"] %>
87+
cache:
88+
<<: *primary_production
89+
database: jbakerdev_production_cache
90+
migrations_paths: db/cache_migrate
91+
queue:
92+
<<: *primary_production
93+
database: jbakerdev_production_queue
94+
migrations_paths: db/queue_migrate
95+
cable:
96+
<<: *primary_production
97+
database: jbakerdev_production_cable
98+
migrations_paths: db/cable_migrate

config/environments/production.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@
4747
config.active_support.report_deprecations = false
4848

4949
# Replace the default in-process memory cache store with a durable alternative.
50-
# config.cache_store = :mem_cache_store
50+
config.cache_store = :solid_cache_store
5151

5252
# Replace the default in-process and non-durable queuing backend for Active Job.
53-
# config.active_job.queue_adapter = :resque
53+
config.active_job.queue_adapter = :solid_queue
54+
config.solid_queue.connects_to = { database: { writing: :queue } }
5455

5556
# Ignore bad email addresses and do not raise email delivery errors.
5657
# Set this to true and configure the email server for immediate delivery to raise delivery errors.

config/puma.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
# Allow puma to be restarted by `bin/rails restart` command.
3434
plugin :tmp_restart
3535

36+
# Run the Solid Queue supervisor inside of Puma for single-server deployments
37+
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
38+
3639
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
3740
# In other environments, only set the PID file if requested.
3841
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

config/queue.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
default: &default
2+
dispatchers:
3+
- polling_interval: 1
4+
batch_size: 500
5+
workers:
6+
- queues: "*"
7+
threads: 3
8+
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
9+
polling_interval: 0.1
10+
11+
development:
12+
<<: *default
13+
14+
test:
15+
<<: *default
16+
17+
production:
18+
<<: *default

config/recurring.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# production:
2+
# periodic_cleanup:
3+
# class: CleanSoftDeletedRecordsJob
4+
# queue: background
5+
# args: [ 1000, { batch_size: 500 } ]
6+
# schedule: every hour
7+
# periodic_command:
8+
# command: "SoftDeletedRecord.due.delete_all"
9+
# priority: 2
10+
# schedule: at 5am every day

0 commit comments

Comments
 (0)