Skip to content

Commit

Permalink
GoodJob: init
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Nov 7, 2023
1 parent c7593c4 commit c9743c7
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ gem 'mini_magick', '~> 4.9.4'
gem "image_processing", ">= 1.2"

gem 'statesman', '~> 10.0'
gem 'sidekiq', '~> 6.4'
gem 'sidekiq-failures', '~> 1.0.0'
gem 'down', '~> 5.0'
gem 'addressable', '~> 2.5.0'
gem 'handlebars_assets', '~> 0.23.0'
Expand Down Expand Up @@ -145,3 +143,5 @@ group :test do
end

gem 'rexml'

gem "good_job", "~> 3.21"
23 changes: 14 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ GEM
zeitwerk (~> 2.6)
dumb_delegator (1.0.0)
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
ethon (0.16.0)
ffi (>= 1.15.0)
exception_notification (4.4.3)
Expand All @@ -305,6 +307,9 @@ GEM
rake
flamegraph (0.9.5)
foreman (0.87.2)
fugit (1.9.0)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
fx (0.8.0)
activerecord (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -363,6 +368,13 @@ GEM
rchardet (~> 1.8)
globalid (1.2.1)
activesupport (>= 6.1)
good_job (3.21.0)
activejob (>= 6.0.0)
activerecord (>= 6.0.0)
concurrent-ruby (>= 1.0.2)
fugit (>= 1.1)
railties (>= 6.0.0)
thor (>= 0.14.1)
haml (5.2.2)
temple (>= 0.8.0)
tilt
Expand Down Expand Up @@ -539,6 +551,7 @@ GEM
nokogiri (~> 1.6)
rails (>= 5.0, < 7.1)
rdf
raabro (1.4.0)
racc (1.7.1)
rack (2.2.8)
rack-cors (2.0.1)
Expand Down Expand Up @@ -587,7 +600,6 @@ GEM
link_header (~> 0.0, >= 0.0.8)
rdf-vocab (3.3.0)
rdf (~> 3.3)
redis (4.8.1)
regexp_parser (2.8.1)
request_store (1.5.1)
rack (>= 1.4)
Expand Down Expand Up @@ -661,12 +673,6 @@ GEM
down (~> 5.0)
http (>= 3.2, < 6)
shrine (>= 3.0.0.rc, < 4)
sidekiq (6.5.9)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq-failures (1.0.4)
sidekiq (>= 4.0.0)
simple_form (5.3.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
Expand Down Expand Up @@ -793,6 +799,7 @@ DEPENDENCIES
geoblacklight-icons!
geoblacklight_admin (~> 0.3)
geoblacklight_sidecar_images!
good_job (~> 3.21)
haml
handlebars_assets (~> 0.23.0)
image_processing (>= 1.2)
Expand Down Expand Up @@ -824,8 +831,6 @@ DEPENDENCIES
sass-rails (~> 5.0)
sd_notify (>= 0.1.0)
selenium-webdriver
sidekiq (~> 6.4)
sidekiq-failures (~> 1.0.0)
sitemap_generator (~> 6.0.2)
solr_wrapper!
spring
Expand Down
8 changes: 3 additions & 5 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
development:
adapter: async
adapter: postgresql

test:
adapter: async
adapter: postgresql

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: geoblacklight_production
adapter: postgresql
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# Google Analytics - Dev
config.google_analytics = 'UA-82483267-2'

config.active_job.queue_adapter = :sidekiq
config.active_job.queue_adapter = :good_job

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
config.google_analytics = 'UA-82483267-1'

# Background jobs
config.active_job.queue_adapter = :sidekiq
config.active_job.queue_adapter = :good_job

# Exception email notification
Rails.application.config.middleware.use ExceptionNotification::Rack,
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
namespace :admin do

authenticate :user, ->(user) { user.admin? } do
mount Sidekiq::Web => "/sidekiq"
mount GoodJob::Engine => 'good_job'
end

devise_for :users, controllers: {invitations: "devise/invitations"}, skip: [:registrations]
Expand Down
88 changes: 88 additions & 0 deletions db/migrate/20231106215104_create_good_jobs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# frozen_string_literal: true

class CreateGoodJobs < ActiveRecord::Migration[6.1]
def change
# Uncomment for Postgres v12 or earlier to enable gen_random_uuid() support
# enable_extension 'pgcrypto'

create_table :good_jobs, id: :uuid do |t|
t.text :queue_name
t.integer :priority
t.jsonb :serialized_params
t.datetime :scheduled_at
t.datetime :performed_at
t.datetime :finished_at
t.text :error

t.timestamps

t.uuid :active_job_id
t.text :concurrency_key
t.text :cron_key
t.uuid :retried_good_job_id
t.datetime :cron_at

t.uuid :batch_id
t.uuid :batch_callback_id

t.boolean :is_discrete
t.integer :executions_count
t.text :job_class
t.integer :error_event, limit: 2
end

create_table :good_job_batches, id: :uuid do |t|
t.timestamps
t.text :description
t.jsonb :serialized_properties
t.text :on_finish
t.text :on_success
t.text :on_discard
t.text :callback_queue_name
t.integer :callback_priority
t.datetime :enqueued_at
t.datetime :discarded_at
t.datetime :finished_at
end

create_table :good_job_executions, id: :uuid do |t|
t.timestamps

t.uuid :active_job_id, null: false
t.text :job_class
t.text :queue_name
t.jsonb :serialized_params
t.datetime :scheduled_at
t.datetime :finished_at
t.text :error
t.integer :error_event, limit: 2
end

create_table :good_job_processes, id: :uuid do |t|
t.timestamps
t.jsonb :state
end

create_table :good_job_settings, id: :uuid do |t|
t.timestamps
t.text :key
t.jsonb :value
t.index :key, unique: true
end

add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: "index_good_jobs_on_scheduled_at"
add_index :good_jobs, [:queue_name, :scheduled_at], where: "(finished_at IS NULL)", name: :index_good_jobs_on_queue_name_and_scheduled_at
add_index :good_jobs, [:active_job_id, :created_at], name: :index_good_jobs_on_active_job_id_and_created_at
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished
add_index :good_jobs, [:cron_key, :created_at], name: :index_good_jobs_on_cron_key_and_created_at
add_index :good_jobs, [:cron_key, :cron_at], name: :index_good_jobs_on_cron_key_and_cron_at, unique: true
add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id
add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished
add_index :good_jobs, [:batch_id], where: "batch_id IS NOT NULL"
add_index :good_jobs, [:batch_callback_id], where: "batch_callback_id IS NOT NULL"

add_index :good_job_executions, [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at
end
end
79 changes: 78 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_10_09_160910) do
ActiveRecord::Schema.define(version: 2023_11_06_215104) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -272,6 +272,83 @@
t.datetime "updated_at", precision: 6, null: false
end

create_table "good_job_batches", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.text "description"
t.jsonb "serialized_properties"
t.text "on_finish"
t.text "on_success"
t.text "on_discard"
t.text "callback_queue_name"
t.integer "callback_priority"
t.datetime "enqueued_at"
t.datetime "discarded_at"
t.datetime "finished_at"
end

create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.uuid "active_job_id", null: false
t.text "job_class"
t.text "queue_name"
t.jsonb "serialized_params"
t.datetime "scheduled_at"
t.datetime "finished_at"
t.text "error"
t.integer "error_event", limit: 2
t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at"
end

create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.jsonb "state"
end

create_table "good_job_settings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.text "key"
t.jsonb "value"
t.index ["key"], name: "index_good_job_settings_on_key", unique: true
end

create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "queue_name"
t.integer "priority"
t.jsonb "serialized_params"
t.datetime "scheduled_at"
t.datetime "performed_at"
t.datetime "finished_at"
t.text "error"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.uuid "active_job_id"
t.text "concurrency_key"
t.text "cron_key"
t.uuid "retried_good_job_id"
t.datetime "cron_at"
t.uuid "batch_id"
t.uuid "batch_callback_id"
t.boolean "is_discrete"
t.integer "executions_count"
t.text "job_class"
t.integer "error_event", limit: 2
t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at"
t.index ["active_job_id"], name: "index_good_jobs_on_active_job_id"
t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)"
t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)"
t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)"
t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at"
t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at", unique: true
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))"
t.index ["priority", "created_at"], name: "index_good_jobs_jobs_on_priority_created_at_when_unfinished", order: { priority: "DESC NULLS LAST" }, where: "(finished_at IS NULL)"
t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)"
t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)"
end

create_table "image_upload_transitions", force: :cascade do |t|
t.string "to_state", null: false
t.text "metadata"
Expand Down

0 comments on commit c9743c7

Please sign in to comment.