Skip to content

Commit 7f82994

Browse files
authored
Drop litestack (#78)
* update deps and Vite * remove warning message * replace litestack by rails defaults * lint * fix tests
1 parent 6a2fadc commit 7f82994

25 files changed

+431
-69
lines changed

Gemfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem "rails", "~> 7.1.0"
1010
gem "propshaft"
1111

1212
# Use sqlite3 as the database for Active Record
13-
# gem "sqlite3", "~> 1.4"
13+
gem "sqlite3", "~> 1.4"
1414

1515
# Use the Puma web server [https://github.com/puma/puma]
1616
gem "puma"
@@ -84,7 +84,12 @@ end
8484

8585
gem "pagy", "~> 6.0"
8686
gem "dockerfile-rails", ">= 1.2", group: :development
87-
gem "litestack"
87+
88+
gem "activerecord-enhancedsqlite3-adapter"
89+
gem "litestream", "~> 0.10.1"
90+
gem "solid_cache"
91+
gem "solid_queue"
92+
8893
gem "inline_svg", "~> 1.9"
8994
gem "net-http", "~> 0.3.2"
9095
gem "meilisearch-rails"

Gemfile.lock

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ GEM
5959
activemodel (= 7.1.3.4)
6060
activesupport (= 7.1.3.4)
6161
timeout (>= 0.4.0)
62+
activerecord-enhancedsqlite3-adapter (0.8.0)
63+
activerecord (>= 7.1)
64+
sqlite3 (>= 1.6)
6265
activestorage (7.1.3.4)
6366
actionpack (= 7.1.3.4)
6467
activejob (= 7.1.3.4)
@@ -160,6 +163,11 @@ GEM
160163
smart_properties
161164
error_highlight (0.6.0)
162165
erubi (1.12.0)
166+
et-orbi (1.2.11)
167+
tzinfo
168+
fugit (1.11.0)
169+
et-orbi (~> 1, >= 1.2.11)
170+
raabro (~> 1.4)
163171
globalid (1.2.1)
164172
activesupport (>= 6.1)
165173
groupdate (6.4.0)
@@ -183,13 +191,19 @@ GEM
183191
json (2.7.2)
184192
language_server-protocol (3.17.0.3)
185193
lint_roller (1.1.0)
186-
litestack (0.4.4)
187-
erubi (~> 1)
188-
oj (~> 3)
189-
rack (~> 3)
190-
rackup (~> 2)
191-
sqlite3 (>= 1.6.0, < 2.0.0)
192-
tilt (~> 2)
194+
litestream (0.10.3)
195+
logfmt (>= 0.0.10)
196+
sqlite3
197+
litestream (0.10.3-arm64-darwin)
198+
logfmt (>= 0.0.10)
199+
sqlite3
200+
litestream (0.10.3-x86_64-darwin)
201+
logfmt (>= 0.0.10)
202+
sqlite3
203+
litestream (0.10.3-x86_64-linux)
204+
logfmt (>= 0.0.10)
205+
sqlite3
206+
logfmt (0.0.10)
193207
loofah (2.22.0)
194208
crass (~> 1.0.2)
195209
nokogiri (>= 1.12.0)
@@ -233,10 +247,8 @@ GEM
233247
racc (~> 1.4)
234248
nokogiri (1.16.5-x86_64-linux)
235249
racc (~> 1.4)
236-
oj (3.16.3)
237-
bigdecimal (>= 3.0)
238250
pagy (6.5.0)
239-
parallel (1.24.0)
251+
parallel (1.25.1)
240252
parser (3.3.2.0)
241253
ast (~> 2.4.1)
242254
racc
@@ -251,6 +263,7 @@ GEM
251263
public_suffix (5.0.5)
252264
puma (6.4.2)
253265
nio4r (~> 2.0)
266+
raabro (1.4.0)
254267
racc (1.8.0)
255268
rack (3.1.0)
256269
rack-mini-profiler (3.3.1)
@@ -308,8 +321,8 @@ GEM
308321
regexp_parser (2.9.2)
309322
reline (0.5.8)
310323
io-console (~> 0.5)
311-
rexml (3.2.8)
312-
strscan (>= 3.0.9)
324+
rexml (3.3.0)
325+
strscan
313326
rubocop (1.63.5)
314327
json (~> 2.3)
315328
language_server-protocol (>= 3.17.0)
@@ -343,7 +356,17 @@ GEM
343356
sitemap_generator (6.3.0)
344357
builder (~> 3.0)
345358
smart_properties (1.17.0)
346-
sorbet-runtime (0.5.11422)
359+
solid_cache (0.6.0)
360+
activejob (>= 7)
361+
activerecord (>= 7)
362+
railties (>= 7)
363+
solid_queue (0.3.2)
364+
activejob (>= 7.1)
365+
activerecord (>= 7.1)
366+
concurrent-ruby (>= 1.3.1)
367+
fugit (~> 1.11.0)
368+
railties (>= 7.1)
369+
sorbet-runtime (0.5.11428)
347370
sqlite3 (1.7.3-aarch64-linux)
348371
sqlite3 (1.7.3-arm64-darwin)
349372
sqlite3 (1.7.3-x86_64-darwin)
@@ -365,7 +388,6 @@ GEM
365388
stringio (3.1.0)
366389
strscan (3.1.0)
367390
thor (1.3.1)
368-
tilt (2.3.0)
369391
timeout (0.4.1)
370392
turbo-rails (2.0.5)
371393
actionpack (>= 6.0.0)
@@ -413,6 +435,7 @@ PLATFORMS
413435
x86_64-linux
414436

415437
DEPENDENCIES
438+
activerecord-enhancedsqlite3-adapter
416439
ahoy_matey (~> 4.2)
417440
annotate
418441
appsignal (~> 3.4)
@@ -432,7 +455,7 @@ DEPENDENCIES
432455
groupdate (~> 6.2)
433456
inline_svg (~> 1.9)
434457
jbuilder
435-
litestack
458+
litestream (~> 0.10.1)
436459
meilisearch-rails
437460
meta-tags (~> 2.18)
438461
net-http (~> 0.3.2)
@@ -446,6 +469,9 @@ DEPENDENCIES
446469
ruby-lsp-rails
447470
selenium-webdriver
448471
sitemap_generator (~> 6.3)
472+
solid_cache
473+
solid_queue
474+
sqlite3 (~> 1.4)
449475
standardrb (~> 1.0)
450476
turbo-rails
451477
tzinfo-data

app/jobs/application_job.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class ApplicationJob < ActiveJob::Base
2-
include Litejob
32
# Automatically retry jobs that encountered a deadlock
43
# retry_on ActiveRecord::Deadlocked
54

config/cable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
development:
2-
adapter: litecable
2+
adapter: async
33

44
test:
5-
adapter: litecable
5+
adapter: async
66

77
production:
8-
adapter: litecable
8+
adapter: async

config/database.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,36 @@
55
# gem "sqlite3"
66
#
77
default: &default
8-
adapter: litedb
9-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 10 } %>
8+
adapter: sqlite3
9+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
1010
timeout: 5000
1111

1212
# DATABASE CONFIGURATIONS
1313
primary: &primary
1414
<<: *default
1515
database: storage/<%= Rails.env %>_rubyvideo.sqlite3
1616

17+
cache: &cache
18+
<<: *default
19+
migrations_paths: db/cache_migrate
20+
database: storage/<%= Rails.env %>-cache.sqlite3
21+
22+
queue: &queue
23+
<<: *default
24+
migrations_paths: db/queue_migrate
25+
database: storage/<%= Rails.env %>-queue.sqlite3
26+
1727
development:
1828
primary: *primary
29+
cache: *cache
30+
queue: *queue
1931

2032
test:
2133
primary: *primary
34+
cache: *cache
35+
queue: *queue
2236

2337
production:
2438
primary: *primary
39+
cache: *cache
40+
queue: *queue

config/environments/development.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
config.action_controller.perform_caching = true
2525
config.action_controller.enable_fragment_cache_logging = true
2626

27-
config.cache_store = :litecache, {path: "./storage/cache.development.db"}
27+
config.cache_store = :solid_cache_store
2828
config.public_file_server.headers = {
2929
"Cache-Control" => "public, max-age=#{2.days.to_i}"
3030
}

config/environments/production.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
6262

6363
# Use a different cache store in production.
64-
config.cache_store = :litecache, {path: "./storage/cache.db"}
64+
config.cache_store = :solid_cache_store
6565

6666
# Use a real queuing backend for Active Job (and separate queues per environment).
67-
# config.active_job.queue_adapter = :resque
68-
# config.active_job.queue_name_prefix = "rubyvideo_production"
67+
config.active_job.queue_adapter = :solid_queue
68+
config.solid_queue.connects_to = {database: {writing: :queue, reading: :queue}}
6969

7070
config.action_mailer.perform_caching = false
7171

config/environments/test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
# Show full error reports and disable caching.
2828
config.consider_all_requests_local = true
2929
config.action_controller.perform_caching = false
30-
config.cache_store = :memory_store
31-
# config.cache_store = :litecache, {path: "./storage/cache.test.db"} when new version of litestack is released
30+
config.cache_store = :solid_cache_store
3231

3332
# Raise exceptions instead of rendering exception templates.
3433
config.action_dispatch.show_exceptions = false
@@ -63,4 +62,6 @@
6362

6463
# Raise error when a before_action's only/except options reference missing actions
6564
config.action_controller.raise_on_missing_callback_actions = true
65+
66+
config.active_job.queue_adapter = :test
6667
end

config/litecable.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

config/litejob.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/puma.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Any libraries that use thread pools should be configured to match
88
# the maximum value specified for Puma. Default is set to 5 threads for minimum
99
# and maximum; this matches the default thread size of Active Record.
10-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
10+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 3 }
1111
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
1212
threads min_threads_count, max_threads_count
1313

config/solid_cache.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
default: &default
2+
database: cache
3+
store_options:
4+
max_age: <%= 1.week.to_i %>
5+
max_size: <%= 512.megabytes %>
6+
namespace: <%= Rails.env %>
7+
8+
development:
9+
<<: *default
10+
11+
test:
12+
<<: *default
13+
14+
production:
15+
<<: *default

config/solid_queue.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
default: &default
2+
dispatchers:
3+
- polling_interval: 1
4+
batch_size: 500
5+
recurring_tasks:
6+
# periodic_litestream_backup_verfication_job:
7+
# class: Litestream::VerificationJob
8+
# args: []
9+
# schedule: every day at 1am EST
10+
workers:
11+
- queues: "*"
12+
threads: 3
13+
processes: 1
14+
polling_interval: 0.1
15+
16+
development:
17+
<<: *default
18+
19+
test:
20+
<<: *default
21+
22+
production:
23+
<<: *default
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This migration comes from solid_cache (originally 20230724121448)
2+
class CreateSolidCacheEntries < ActiveRecord::Migration[7.0]
3+
def change
4+
create_table :solid_cache_entries do |t|
5+
t.binary :key, null: false, limit: 1024
6+
t.binary :value, null: false, limit: 512.megabytes
7+
t.datetime :created_at, null: false
8+
9+
t.index :key, unique: true
10+
end
11+
end
12+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This migration comes from solid_cache (originally 20240108155507)
2+
class AddKeyHashAndByteSizeToSolidCacheEntries < ActiveRecord::Migration[7.0]
3+
def change
4+
change_table :solid_cache_entries do |t|
5+
t.column :key_hash, :integer, null: true, limit: 8
6+
t.column :byte_size, :integer, null: true, limit: 4
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This migration comes from solid_cache (originally 20240110111600)
2+
class AddKeyHashAndByteSizeIndexesAndNullConstraintsToSolidCacheEntries < ActiveRecord::Migration[7.0]
3+
def change
4+
change_table :solid_cache_entries, bulk: true do |t|
5+
t.change_null :key_hash, false
6+
t.change_null :byte_size, false
7+
t.index :key_hash, unique: true
8+
t.index [:key_hash, :byte_size]
9+
t.index :byte_size
10+
end
11+
end
12+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This migration comes from solid_cache (originally 20240110111702)
2+
class RemoveKeyIndexFromSolidCacheEntries < ActiveRecord::Migration[7.0]
3+
def change
4+
change_table :solid_cache_entries do |t|
5+
t.remove_index :key, unique: true
6+
end
7+
end
8+
end

db/cache_schema.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is auto-generated from the current state of the database. Instead
2+
# of editing this file, please use the migrations feature of Active Record to
3+
# incrementally modify your database, and then regenerate this schema definition.
4+
#
5+
# This file is the source Rails uses to define your schema when running `bin/rails
6+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7+
# be faster and is potentially less error prone than running all of your
8+
# migrations from scratch. Old migrations may fail to apply correctly if those
9+
# migrations use external dependencies or application code.
10+
#
11+
# It's strongly recommended that you check this file into your version control system.
12+
13+
ActiveRecord::Schema[7.1].define(version: 2024_05_16_085651) do
14+
create_table "solid_cache_entries", force: :cascade do |t|
15+
t.binary "key", limit: 1024, null: false
16+
t.binary "value", limit: 536870912, null: false
17+
t.datetime "created_at", null: false
18+
t.integer "key_hash", limit: 8, null: false
19+
t.integer "byte_size", limit: 4, null: false
20+
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
21+
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
22+
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
23+
end
24+
end

0 commit comments

Comments
 (0)