Skip to content

Commit

Permalink
Drop litestack (#78)
Browse files Browse the repository at this point in the history
* update deps and Vite

* remove warning message

* replace litestack by rails defaults

* lint

* fix tests
  • Loading branch information
adrienpoly committed Jun 11, 2024
1 parent 6a2fadc commit 7f82994
Show file tree
Hide file tree
Showing 25 changed files with 431 additions and 69 deletions.
9 changes: 7 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem "rails", "~> 7.1.0"
gem "propshaft"

# Use sqlite3 as the database for Active Record
# gem "sqlite3", "~> 1.4"
gem "sqlite3", "~> 1.4"

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

gem "pagy", "~> 6.0"
gem "dockerfile-rails", ">= 1.2", group: :development
gem "litestack"

gem "activerecord-enhancedsqlite3-adapter"
gem "litestream", "~> 0.10.1"
gem "solid_cache"
gem "solid_queue"

gem "inline_svg", "~> 1.9"
gem "net-http", "~> 0.3.2"
gem "meilisearch-rails"
Expand Down
56 changes: 41 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ GEM
activemodel (= 7.1.3.4)
activesupport (= 7.1.3.4)
timeout (>= 0.4.0)
activerecord-enhancedsqlite3-adapter (0.8.0)
activerecord (>= 7.1)
sqlite3 (>= 1.6)
activestorage (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
Expand Down Expand Up @@ -160,6 +163,11 @@ GEM
smart_properties
error_highlight (0.6.0)
erubi (1.12.0)
et-orbi (1.2.11)
tzinfo
fugit (1.11.0)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
groupdate (6.4.0)
Expand All @@ -183,13 +191,19 @@ GEM
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
litestack (0.4.4)
erubi (~> 1)
oj (~> 3)
rack (~> 3)
rackup (~> 2)
sqlite3 (>= 1.6.0, < 2.0.0)
tilt (~> 2)
litestream (0.10.3)
logfmt (>= 0.0.10)
sqlite3
litestream (0.10.3-arm64-darwin)
logfmt (>= 0.0.10)
sqlite3
litestream (0.10.3-x86_64-darwin)
logfmt (>= 0.0.10)
sqlite3
litestream (0.10.3-x86_64-linux)
logfmt (>= 0.0.10)
sqlite3
logfmt (0.0.10)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -233,10 +247,8 @@ GEM
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
oj (3.16.3)
bigdecimal (>= 3.0)
pagy (6.5.0)
parallel (1.24.0)
parallel (1.25.1)
parser (3.3.2.0)
ast (~> 2.4.1)
racc
Expand All @@ -251,6 +263,7 @@ GEM
public_suffix (5.0.5)
puma (6.4.2)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.0)
rack (3.1.0)
rack-mini-profiler (3.3.1)
Expand Down Expand Up @@ -308,8 +321,8 @@ GEM
regexp_parser (2.9.2)
reline (0.5.8)
io-console (~> 0.5)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.3.0)
strscan
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down Expand Up @@ -343,7 +356,17 @@ GEM
sitemap_generator (6.3.0)
builder (~> 3.0)
smart_properties (1.17.0)
sorbet-runtime (0.5.11422)
solid_cache (0.6.0)
activejob (>= 7)
activerecord (>= 7)
railties (>= 7)
solid_queue (0.3.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
sorbet-runtime (0.5.11428)
sqlite3 (1.7.3-aarch64-linux)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-darwin)
Expand All @@ -365,7 +388,6 @@ GEM
stringio (3.1.0)
strscan (3.1.0)
thor (1.3.1)
tilt (2.3.0)
timeout (0.4.1)
turbo-rails (2.0.5)
actionpack (>= 6.0.0)
Expand Down Expand Up @@ -413,6 +435,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activerecord-enhancedsqlite3-adapter
ahoy_matey (~> 4.2)
annotate
appsignal (~> 3.4)
Expand All @@ -432,7 +455,7 @@ DEPENDENCIES
groupdate (~> 6.2)
inline_svg (~> 1.9)
jbuilder
litestack
litestream (~> 0.10.1)
meilisearch-rails
meta-tags (~> 2.18)
net-http (~> 0.3.2)
Expand All @@ -446,6 +469,9 @@ DEPENDENCIES
ruby-lsp-rails
selenium-webdriver
sitemap_generator (~> 6.3)
solid_cache
solid_queue
sqlite3 (~> 1.4)
standardrb (~> 1.0)
turbo-rails
tzinfo-data
Expand Down
1 change: 0 additions & 1 deletion app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ApplicationJob < ActiveJob::Base
include Litejob
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

Expand Down
6 changes: 3 additions & 3 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
development:
adapter: litecable
adapter: async

test:
adapter: litecable
adapter: async

production:
adapter: litecable
adapter: async
20 changes: 18 additions & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,36 @@
# gem "sqlite3"
#
default: &default
adapter: litedb
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 10 } %>
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

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

cache: &cache
<<: *default
migrations_paths: db/cache_migrate
database: storage/<%= Rails.env %>-cache.sqlite3

queue: &queue
<<: *default
migrations_paths: db/queue_migrate
database: storage/<%= Rails.env %>-queue.sqlite3

development:
primary: *primary
cache: *cache
queue: *queue

test:
primary: *primary
cache: *cache
queue: *queue

production:
primary: *primary
cache: *cache
queue: *queue
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :litecache, {path: "./storage/cache.development.db"}
config.cache_store = :solid_cache_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
Expand Down
6 changes: 3 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

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

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

config.action_mailer.perform_caching = false

Expand Down
5 changes: 3 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :memory_store
# config.cache_store = :litecache, {path: "./storage/cache.test.db"} when new version of litestack is released
config.cache_store = :solid_cache_store

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
Expand Down Expand Up @@ -63,4 +62,6 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

config.active_job.queue_adapter = :test
end
4 changes: 0 additions & 4 deletions config/litecable.yml

This file was deleted.

11 changes: 0 additions & 11 deletions config/litejob.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 3 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

Expand Down
15 changes: 15 additions & 0 deletions config/solid_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: &default
database: cache
store_options:
max_age: <%= 1.week.to_i %>
max_size: <%= 512.megabytes %>
namespace: <%= Rails.env %>

development:
<<: *default

test:
<<: *default

production:
<<: *default
23 changes: 23 additions & 0 deletions config/solid_queue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default: &default
dispatchers:
- polling_interval: 1
batch_size: 500
recurring_tasks:
# periodic_litestream_backup_verfication_job:
# class: Litestream::VerificationJob
# args: []
# schedule: every day at 1am EST
workers:
- queues: "*"
threads: 3
processes: 1
polling_interval: 0.1

development:
<<: *default

test:
<<: *default

production:
<<: *default
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from solid_cache (originally 20230724121448)
class CreateSolidCacheEntries < ActiveRecord::Migration[7.0]
def change
create_table :solid_cache_entries do |t|
t.binary :key, null: false, limit: 1024
t.binary :value, null: false, limit: 512.megabytes
t.datetime :created_at, null: false

t.index :key, unique: true
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This migration comes from solid_cache (originally 20240108155507)
class AddKeyHashAndByteSizeToSolidCacheEntries < ActiveRecord::Migration[7.0]
def change
change_table :solid_cache_entries do |t|
t.column :key_hash, :integer, null: true, limit: 8
t.column :byte_size, :integer, null: true, limit: 4
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from solid_cache (originally 20240110111600)
class AddKeyHashAndByteSizeIndexesAndNullConstraintsToSolidCacheEntries < ActiveRecord::Migration[7.0]
def change
change_table :solid_cache_entries, bulk: true do |t|
t.change_null :key_hash, false
t.change_null :byte_size, false
t.index :key_hash, unique: true
t.index [:key_hash, :byte_size]
t.index :byte_size
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This migration comes from solid_cache (originally 20240110111702)
class RemoveKeyIndexFromSolidCacheEntries < ActiveRecord::Migration[7.0]
def change
change_table :solid_cache_entries do |t|
t.remove_index :key, unique: true
end
end
end
24 changes: 24 additions & 0 deletions db/cache_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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[7.1].define(version: 2024_05_16_085651) do
create_table "solid_cache_entries", force: :cascade do |t|
t.binary "key", limit: 1024, null: false
t.binary "value", limit: 536870912, null: false
t.datetime "created_at", null: false
t.integer "key_hash", limit: 8, null: false
t.integer "byte_size", limit: 4, null: false
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
end
end
Loading

0 comments on commit 7f82994

Please sign in to comment.