Skip to content

Commit

Permalink
Upgrade to good_job 4.x (#4916)
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins authored Jul 24, 2024
1 parent e2f1aef commit e1ae157
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem "dogstatsd-ruby", "~> 5.5"
gem "google-protobuf", "~> 4.27"
gem "faraday", "~> 2.10"
gem "faraday-retry", "~> 2.2"
gem "good_job", "~> 3.29"
gem "good_job", "~> 3.99"
gem "gravtastic", "~> 3.2"
gem "honeybadger", "~> 5.5.1", require: false # see https://github.com/rubygems/rubygems.org/pull/4598
gem "http_accept_language", "~> 2.1"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ GEM
ffi (~> 1.0)
globalid (1.2.1)
activesupport (>= 6.1)
good_job (3.29.5)
good_job (3.99.1)
activejob (>= 6.0.0)
activerecord (>= 6.0.0)
concurrent-ruby (>= 1.0.2)
Expand Down Expand Up @@ -826,7 +826,7 @@ DEPENDENCIES
faraday-retry (~> 2.2)
faraday_middleware-aws-sigv4 (~> 1.0)
gem_server_conformance (~> 0.1.4)
good_job (~> 3.29)
good_job (~> 3.99)
google-protobuf (~> 4.27)
gravtastic (~> 3.2)
groupdate (~> 6.2)
Expand Down Expand Up @@ -1005,7 +1005,7 @@ CHECKSUMS
gem_server_conformance (0.1.4) sha256=ee404d5405eabcb6f7ab440d2193177375481a77bfa0ec3106165dd6c8e733bb
get_process_mem (0.2.7) sha256=4afd3c3641dd6a817c09806c7d6d509d8a9984512ac38dea8b917426bbf77eba
globalid (1.2.1) sha256=70bf76711871f843dbba72beb8613229a49429d1866828476f9c9d6ccc327ce9
good_job (3.29.5) sha256=3d71236c7e89b9678ba0cf16d6a93b9ee2ff12795959a0c10f77fd52f6479a13
good_job (3.99.1) sha256=7d3869d8a8ee8ef7048fee5d746f41c21987b7822c20038a2f773036bef0830a
google-protobuf (4.27.2) sha256=9f69eb20acde6e3cf3cd197c09f38911cd7eed5fdf1bf4d4bce4c55e9dc9966f
gravtastic (3.2.6) sha256=ef98abcecf7c402b61cff1ae7c50a2c6d97dd22bac21ea9b421ce05bc03d734f
groupdate (6.4.0) sha256=65940645bf2a48f9b2d10ab7a1d19bdc78f3c89559d8fce39cea3448a15aec54
Expand Down
6 changes: 4 additions & 2 deletions config/initializers/statsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@

ActiveSupport::Notifications.subscribe("perform_job.good_job") do |event|
execution = event.payload[:execution]
# TODO: remove || execution after GoodJob 4 upgrade
job = event.payload[:job] || execution

result = if event.payload[:retried] || execution.retried_good_job_id.present?
result = if event.payload[:retried] || job.retried_good_job_id.present?
:retried
elsif event.payload[:unhandled_error]
:unhandled_error
Expand All @@ -72,7 +74,7 @@
job_class: execution.serialized_params['job_class'],
exception: event.payload.dig(:exception, 0),
queue: execution.queue_name,
priority: execution.priority,
priority: job.priority,
result:
}

Expand Down
15 changes: 15 additions & 0 deletions db/migrate/20240722182907_create_good_job_execution_duration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class CreateGoodJobExecutionDuration < ActiveRecord::Migration[7.1]
def change
reversible do |dir|
dir.up do
# Ensure this incremental update migration is idempotent
# with monolithic install migration.
return if connection.column_exists?(:good_job_executions, :duration)
end
end

add_column :good_job_executions, :duration, :interval
end
end
3 changes: 2 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[7.1].define(version: 2024_07_12_003336) do
ActiveRecord::Schema[7.1].define(version: 2024_07_22_182907) do
# These are extensions that must be enabled in order to support this database
enable_extension "hstore"
enable_extension "pgcrypto"
Expand Down Expand Up @@ -202,6 +202,7 @@
t.integer "error_event", limit: 2
t.text "error_backtrace", array: true
t.uuid "process_id"
t.interval "duration"
t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at"
t.index ["process_id", "created_at"], name: "index_good_job_executions_on_process_id_and_created_at"
end
Expand Down

0 comments on commit e1ae157

Please sign in to comment.