Use sqlite for cable in development

This commit is contained in:
Eugene Burmakin 2025-05-31 21:27:20 +02:00
parent 48f9036614
commit 551c6e7629
11 changed files with 23 additions and 13 deletions

2
.gitignore vendored
View file

@ -74,3 +74,5 @@
Makefile Makefile
/db/*.sqlite3 /db/*.sqlite3
/db/*.sqlite3-shm
/db/*.sqlite3-wal

View file

@ -12,6 +12,8 @@ This release introduces a new way to run background jobs and cache data. Before
Moving to SolidQueue and SolidCache will require creating new SQLite databases, which will be created automatically when you start the app. They will be stored in the `dawarich_db_data` volume. Moving to SolidQueue and SolidCache will require creating new SQLite databases, which will be created automatically when you start the app. They will be stored in the `dawarich_db_data` volume.
Background jobs interface is now available at `/jobs` page.
## Fixed ## Fixed
@ -23,6 +25,8 @@ Moving to SolidQueue and SolidCache will require creating new SQLite databases,
- SolidQueue is now being used for background jobs instead of Sidekiq. - SolidQueue is now being used for background jobs instead of Sidekiq.
- SolidCable is now being used as ActionCable adapter. - SolidCable is now being used as ActionCable adapter.
- Background jobs are now being run as Puma plugin instead of separate Docker container. - Background jobs are now being run as Puma plugin instead of separate Docker container.
- The `rc` docker image is now being built for amd64 architecture only to speed up the build process.
- Deleting an import now works significantly faster.

View file

@ -9,7 +9,10 @@ class Imports::Destroy
end end
def call def call
@import.destroy! ActiveRecord::Base.transaction do
@import.points.delete_all
@import.destroy!
end
Stats::BulkCalculator.new(@user.id).call Stats::BulkCalculator.new(@user.id).call
end end

View file

@ -21,6 +21,7 @@ class Jobs::Create
raise InvalidJobName, 'Invalid job name' raise InvalidJobName, 'Invalid job name'
end end
# TODO: bulk enqueue reverse geocoding with ActiveJob
points.find_each(&:async_reverse_geocode) points.find_each(&:async_reverse_geocode)
end end
end end

View file

@ -4,7 +4,12 @@
# to make the web console appear. # to make the web console appear.
development: development:
adapter: async adapter: solid_cable
connects_to:
database:
writing: cable
polling_interval: 0.1.seconds
message_retention: 1.day
test: test:
adapter: test adapter: test

View file

@ -26,6 +26,10 @@ development:
<<: *sqlite_default <<: *sqlite_default
database: <%= ENV['CACHE_DATABASE_PATH'] || 'db/cache.sqlite3' %> database: <%= ENV['CACHE_DATABASE_PATH'] || 'db/cache.sqlite3' %>
migrations_paths: db/cache_migrate migrations_paths: db/cache_migrate
cable:
<<: *sqlite_default
database: <%= ENV['CABLE_DATABASE_PATH'] || 'db/cable.sqlite3' %>
migrations_paths: db/cable_migrate
test: test:
primary: primary:

View file

@ -6,7 +6,7 @@ default: &default
workers: workers:
- queues: "*" - queues: "*"
threads: 3 threads: 3
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> processes: <%= ENV['BACKGROUND_PROCESSING_CONCURRENCY'] || ENV.fetch("JOB_CONCURRENCY", 10) %>
polling_interval: 2 polling_interval: 2
- queues: imports - queues: imports
threads: 5 threads: 5

View file

@ -11,9 +11,6 @@
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 1) do ActiveRecord::Schema[8.0].define(version: 1) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "solid_cable_messages", force: :cascade do |t| create_table "solid_cable_messages", force: :cascade do |t|
t.binary "channel", null: false t.binary "channel", null: false
t.binary "payload", null: false t.binary "payload", null: false
@ -22,5 +19,6 @@ ActiveRecord::Schema[8.0].define(version: 1) do
t.index ["channel"], name: "index_solid_cable_messages_on_channel" t.index ["channel"], name: "index_solid_cable_messages_on_channel"
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash" t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at" t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
t.index ["id"], name: "index_solid_cable_messages_on_id", unique: true
end end
end end

View file

@ -11,9 +11,6 @@
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 1) do ActiveRecord::Schema[8.0].define(version: 1) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "solid_cache_entries", force: :cascade do |t| create_table "solid_cache_entries", force: :cascade do |t|
t.binary "key", null: false t.binary "key", null: false
t.binary "value", null: false t.binary "value", null: false

View file

@ -11,9 +11,6 @@
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 1) do ActiveRecord::Schema[8.0].define(version: 1) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "solid_queue_blocked_executions", force: :cascade do |t| create_table "solid_queue_blocked_executions", force: :cascade do |t|
t.bigint "job_id", null: false t.bigint "job_id", null: false
t.string "queue_name", null: false t.string "queue_name", null: false

View file

@ -106,7 +106,6 @@ services:
- dawarich_public:/var/app/public - dawarich_public:/var/app/public
- dawarich_watched:/var/app/tmp/imports/watched - dawarich_watched:/var/app/tmp/imports/watched
- dawarich_storage:/var/app/storage - dawarich_storage:/var/app/storage
- dawarich_db_data:/dawarich_db_data
networks: networks:
- dawarich - dawarich
stdin_open: true stdin_open: true