good_job 1.99.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -2786
- data/README.md +14 -27
- data/lib/generators/good_job/install_generator.rb +6 -6
- data/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb +1 -0
- data/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb +8 -0
- data/lib/generators/good_job/update_generator.rb +6 -4
- data/lib/good_job/active_job_extensions/concurrency.rb +1 -1
- data/lib/good_job/adapter.rb +6 -36
- data/lib/good_job/configuration.rb +21 -20
- data/lib/good_job/job.rb +9 -65
- data/lib/good_job/lockable.rb +4 -4
- data/lib/good_job/scheduler.rb +3 -1
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +1 -29
- metadata +3 -6
- data/lib/generators/good_job/templates/update/migrations/02_add_active_job_id_concurrency_key_cron_key_to_good_jobs.rb +0 -16
- data/lib/generators/good_job/templates/update/migrations/03_add_active_job_id_index_and_concurrency_key_index_to_good_jobs.rb +0 -36
- data/lib/generators/good_job/templates/update/migrations/04_add_retried_good_job_id_to_good_jobs.rb +0 -14
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migration[5.2]
|
3
|
-
disable_ddl_transaction!
|
4
|
-
|
5
|
-
UPDATE_BATCH_SIZE = 1_000
|
6
|
-
|
7
|
-
class GoodJobJobs < ActiveRecord::Base
|
8
|
-
self.table_name = "good_jobs"
|
9
|
-
end
|
10
|
-
|
11
|
-
def change
|
12
|
-
reversible do |dir|
|
13
|
-
dir.up do
|
14
|
-
# Ensure this incremental update migration is idempotent
|
15
|
-
# with monolithic install migration.
|
16
|
-
return if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id_and_created_at)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
add_index :good_jobs, [:active_job_id, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_active_job_id_and_created_at
|
21
|
-
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", algorithm: :concurrently, name: :index_good_jobs_on_concurrency_key_when_unfinished
|
22
|
-
add_index :good_jobs, [:cron_key, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_cron_key_and_created_at
|
23
|
-
|
24
|
-
return unless defined? GoodJob::Job
|
25
|
-
|
26
|
-
reversible do |dir|
|
27
|
-
dir.up do
|
28
|
-
# Ensure that all `good_jobs` records have an active_job_id value
|
29
|
-
start_time = Time.current
|
30
|
-
loop do
|
31
|
-
break if GoodJobJobs.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/04_add_retried_good_job_id_to_good_jobs.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class AddRetriedGoodJobIdToGoodJobs < ActiveRecord::Migration[5.2]
|
3
|
-
def change
|
4
|
-
reversible do |dir|
|
5
|
-
dir.up do
|
6
|
-
# Ensure this incremental update migration is idempotent
|
7
|
-
# with monolithic install migration.
|
8
|
-
return if connection.column_exists?(:good_jobs, :retried_good_job_id)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
add_column :good_jobs, :retried_good_job_id, :uuid
|
13
|
-
end
|
14
|
-
end
|