delayed_job_heartbeat_plugin 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +83 -80
- data/.github/CODEOWNERS +1 -1
- data/.rubocop.yml +1 -1
- data/Appraisals +10 -5
- data/CHANGELOG.md +19 -8
- data/delayed_job_heartbeat_plugin.gemspec +3 -3
- data/gemfiles/{rails_6.0.gemfile → rails_7.1.gemfile} +2 -2
- data/gemfiles/rails_7.2.gemfile +8 -0
- data/lib/delayed/heartbeat/tasks.rb +1 -1
- data/lib/delayed/heartbeat/version.rb +1 -1
- data/lib/delayed/heartbeat/worker_heartbeat.rb +3 -3
- data/spec/delayed/heartbeat_spec.rb +1 -1
- data/spec/spec_helper.rb +34 -16
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e345f76bdcd070b600dfab6df2b3eb8605b9c782f9e1b889c737f9e928fa3d3
|
4
|
+
data.tar.gz: 9d1a29cf20de158f54c7cb1c56eb6ed39e18112e21af8021c62a2eb911220598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67e3d0bed56aeb692398b6b3bb83cdb11faafd8fdb1f392961ffe61e97537f7918b42927e58f561e7d8b8c643ea6c368fa32bd937d0d8bd483f588d185d54b8
|
7
|
+
data.tar.gz: 409f328c1244d38bc9f161dbfd28e6169b626b0831a896716090b7d05357e3d43688cf448c22494bd2a154a399c5e6c28a4eefc962c606fcf1f639adb055694e
|
data/.circleci/config.yml
CHANGED
@@ -1,81 +1,83 @@
|
|
1
1
|
version: 2.1
|
2
2
|
jobs:
|
3
3
|
lint:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
4
|
+
docker:
|
5
|
+
- image: cimg/ruby:3.1.6
|
6
|
+
working_directory: ~/delayed_job_heartbeat_plugin
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
- restore_cache:
|
10
|
+
keys:
|
11
|
+
- v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
|
12
|
+
- v1-gems-ruby-3.1.6-
|
13
|
+
- run:
|
14
|
+
name: Install Gems
|
15
|
+
command: |
|
16
|
+
if ! bundle check --path=vendor/bundle; then
|
17
|
+
bundle install --path=vendor/bundle --jobs=4 --retry=3
|
18
|
+
bundle clean
|
19
|
+
fi
|
20
|
+
- save_cache:
|
21
|
+
key: v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
|
22
|
+
paths:
|
23
|
+
- "vendor/bundle"
|
24
|
+
- "gemfiles/vendor/bundle"
|
25
|
+
- run:
|
26
|
+
name: Run Rubocop
|
27
|
+
command: bundle exec rubocop --config .rubocop.yml
|
28
28
|
test:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
29
|
+
parameters:
|
30
|
+
gemfile:
|
31
|
+
type: string
|
32
|
+
ruby_version:
|
33
|
+
type: string
|
34
|
+
docker:
|
35
|
+
- image: cimg/ruby:<< parameters.ruby_version >>
|
36
|
+
environment:
|
37
|
+
DB_USER: "circleci"
|
38
|
+
- image: cimg/postgres:12.9
|
39
|
+
environment:
|
40
|
+
POSTGRES_USER: "circleci"
|
41
|
+
POSTGRES_DB: "circle_test"
|
42
|
+
POSTGRES_HOST_AUTH_METHOD: "trust"
|
43
|
+
environment:
|
44
|
+
RACK_ENV: "test"
|
45
|
+
RAILS_ENV: "test"
|
46
|
+
DB_USER: "circleci"
|
47
|
+
ADMIN_DB_NAME: "circle_test"
|
48
|
+
CIRCLE_TEST_REPORTS: "test-results"
|
49
|
+
BUNDLE_GEMFILE: << parameters.gemfile >>
|
50
|
+
working_directory: ~/delayed_job_heartbeat_plugin
|
51
|
+
steps:
|
52
|
+
- checkout
|
53
|
+
- restore_cache:
|
54
|
+
keys:
|
55
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
|
56
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-
|
57
|
+
- run:
|
58
|
+
name: Install Gems
|
59
|
+
command: |
|
60
|
+
if ! bundle check --path=vendor/bundle; then
|
61
|
+
bundle install --path=vendor/bundle --jobs=4 --retry=3
|
62
|
+
bundle clean
|
63
|
+
fi
|
64
|
+
- save_cache:
|
65
|
+
key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
|
66
|
+
paths:
|
67
|
+
- "vendor/bundle"
|
68
|
+
- "gemfiles/vendor/bundle"
|
69
|
+
- run:
|
70
|
+
name: Wait for Database
|
71
|
+
command: dockerize -wait tcp://localhost:5432 -timeout 60s
|
72
|
+
- run:
|
73
|
+
name: Wait for Database User
|
74
|
+
command: t=30; for i in `seq $t`; do psql -h localhost -p 5432 -U circleci -d circle_test -c '\q' && break; [ $i -eq $t ] && return 2; sleep 1; done;
|
75
|
+
- run:
|
76
|
+
name: Run Tests
|
77
|
+
command: |
|
78
|
+
bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
|
79
|
+
- store_test_results:
|
80
|
+
path: "test-results"
|
79
81
|
workflows:
|
80
82
|
build:
|
81
83
|
jobs:
|
@@ -84,10 +86,11 @@ workflows:
|
|
84
86
|
matrix:
|
85
87
|
parameters:
|
86
88
|
gemfile:
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
89
|
+
- gemfiles/rails_6.1.gemfile
|
90
|
+
- gemfiles/rails_7.0.gemfile
|
91
|
+
- gemfiles/rails_7.1.gemfile
|
92
|
+
- gemfiles/rails_7.2.gemfile
|
90
93
|
ruby_version:
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
+
- 3.1.6
|
95
|
+
- 3.2.5
|
96
|
+
- 3.3.4
|
data/.github/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @
|
1
|
+
* @salsify/pim-core-backend
|
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'rails-6.0' do
|
4
|
-
gem 'activerecord', '~> 6.0.4'
|
5
|
-
gem 'activesupport', '~> 6.0.4'
|
6
|
-
end
|
7
|
-
|
8
3
|
appraise 'rails-6.1' do
|
9
4
|
gem 'activerecord', '~> 6.1.5'
|
10
5
|
gem 'activesupport', '~> 6.1.5'
|
@@ -14,3 +9,13 @@ appraise 'rails-7.0' do
|
|
14
9
|
gem 'activerecord', '~> 7.0.2'
|
15
10
|
gem 'activesupport', '~> 7.0.2'
|
16
11
|
end
|
12
|
+
|
13
|
+
appraise 'rails-7.1' do
|
14
|
+
gem 'activerecord', '~> 7.1.3'
|
15
|
+
gem 'activesupport', '~> 7.1.3'
|
16
|
+
end
|
17
|
+
|
18
|
+
appraise 'rails-7.2' do
|
19
|
+
gem 'activerecord', '~> 7.2.0'
|
20
|
+
gem 'activesupport', '~> 7.2.0'
|
21
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## 0.6.0
|
4
|
+
|
5
|
+
- Drop support for Ruby < 3.1
|
6
|
+
- Drop Rails 6.0
|
7
|
+
- Add Rails 7.2
|
8
|
+
**Thanks [@DRSisco](https://github.com/DRSisco)**
|
9
|
+
|
10
|
+
## 0.5.0
|
11
|
+
|
4
12
|
- Drop support for ruby < 2.7
|
5
13
|
- Add support for ruby 3.1
|
6
14
|
- Drop Rails 5.2
|
7
15
|
- Add Rails 7.0
|
8
16
|
|
9
|
-
|
17
|
+
## 0.4.0
|
18
|
+
|
10
19
|
- Use frozen string literals.
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
21
|
+
## 0.3.0
|
22
|
+
|
23
|
+
- Drop support for Ruby < 2.5.
|
24
|
+
- Drop support for Rails < 5.2.
|
25
|
+
- Bugfix for rails version in generated migration files
|
26
|
+
|
27
|
+
## 0.2.0
|
16
28
|
|
17
|
-
|
18
|
-
* Enable correlation between workers and unlocked jobs in results returned from deleting workers
|
29
|
+
- Enable correlation between workers and unlocked jobs in results returned from deleting workers
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.test_files = Dir.glob('spec/**/*')
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.required_ruby_version = '>=
|
28
|
+
spec.required_ruby_version = '>= 3.1'
|
29
29
|
|
30
30
|
spec.add_dependency 'delayed_job', '>= 4.1.0'
|
31
31
|
spec.add_dependency 'delayed_job_active_record', '>= 4.1.0'
|
32
32
|
|
33
|
-
spec.add_development_dependency 'activerecord', ['>=
|
33
|
+
spec.add_development_dependency 'activerecord', ['>= 6.1', '< 7.3']
|
34
34
|
spec.add_development_dependency 'appraisal'
|
35
35
|
spec.add_development_dependency 'bundler'
|
36
36
|
spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency 'rake', '~> 13.0'
|
40
40
|
spec.add_development_dependency 'rspec', '~> 3'
|
41
41
|
spec.add_development_dependency 'rspec_junit_formatter'
|
42
|
-
spec.add_development_dependency 'salsify_rubocop', '~> 1.
|
42
|
+
spec.add_development_dependency 'salsify_rubocop', '~> 1.59.1'
|
43
43
|
spec.add_development_dependency 'simplecov'
|
44
44
|
spec.add_development_dependency 'timecop'
|
45
45
|
end
|
@@ -16,7 +16,7 @@ namespace :delayed do
|
|
16
16
|
|
17
17
|
def print_results(results)
|
18
18
|
puts "Deleted #{results.workers.size} and unlocked #{results.unlocked_jobs.size} orphaned jobs"
|
19
|
-
puts results
|
19
|
+
puts results if verbose? && results.present?
|
20
20
|
end
|
21
21
|
|
22
22
|
def verbose?
|
@@ -46,7 +46,7 @@ module Delayed
|
|
46
46
|
update_heartbeat
|
47
47
|
# Return the connection back to the pool since we won't be needing
|
48
48
|
# it again for a while.
|
49
|
-
Delayed::Backend::ActiveRecord::Job.clear_active_connections!
|
49
|
+
Delayed::Backend::ActiveRecord::Job.connection_handler.clear_active_connections!
|
50
50
|
end
|
51
51
|
rescue StandardError => e
|
52
52
|
# We don't want the worker to continue running if the heartbeat can't be written.
|
@@ -58,8 +58,8 @@ module Delayed
|
|
58
58
|
ensure
|
59
59
|
@stop_reader.close
|
60
60
|
@worker_model.delete
|
61
|
-
#
|
62
|
-
Delayed::Backend::ActiveRecord::Job.clear_active_connections!
|
61
|
+
# NOTE: The built-in Delayed::Plugins::ClearLocks will unlock the jobs for us
|
62
|
+
Delayed::Backend::ActiveRecord::Job.connection_handler.clear_active_connections!
|
63
63
|
end
|
64
64
|
|
65
65
|
def update_heartbeat
|
@@ -42,7 +42,7 @@ describe Delayed::Heartbeat do
|
|
42
42
|
|
43
43
|
let!(:failed_orphaned_job) do
|
44
44
|
Delayed::Job.create!(locked_by: dead_worker.name, locked_at: dead_worker.last_heartbeat_at,
|
45
|
-
|
45
|
+
payload_object: TestJobWithCallbacks.new) do |job|
|
46
46
|
job.attempts = max_attempts - 1
|
47
47
|
end
|
48
48
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,7 @@ require 'database_cleaner'
|
|
16
16
|
require 'delayed_job_heartbeat_plugin'
|
17
17
|
require 'yaml'
|
18
18
|
require 'timecop'
|
19
|
+
require 'pg'
|
19
20
|
|
20
21
|
spec_dir = File.dirname(__FILE__)
|
21
22
|
Dir["#{spec_dir}/support/**/*.rb"].sort.each { |f| require f }
|
@@ -31,34 +32,51 @@ Delayed::Worker.logger.level = Logger::DEBUG
|
|
31
32
|
ActiveRecord::Base.logger = Delayed::Worker.logger
|
32
33
|
ActiveRecord::Migration.verbose = false
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
database_host = ENV.fetch('DB_HOST', 'localhost')
|
36
|
+
database_port = ENV.fetch('DB_PORT', 5432)
|
37
|
+
database_user = ENV.fetch('DB_USER', 'postgres')
|
38
|
+
database_password = ENV.fetch('DB_PASSWORD', 'password')
|
39
|
+
database_url = "postgres://#{database_user}:#{database_password}@#{database_host}:#{database_port}"
|
40
|
+
admin_database_name = "/#{ENV['ADMIN_DB_NAME']}" if ENV['ADMIN_DB_NAME'].present?
|
41
|
+
|
42
|
+
DATABASE_NAME = 'delayed_job_heartbeat_plugin_test'
|
43
|
+
|
44
|
+
def setup_test_database(pg_conn, database_name)
|
45
|
+
pg_conn.exec("DROP DATABASE IF EXISTS #{database_name}")
|
46
|
+
pg_conn.exec("CREATE DATABASE #{database_name}")
|
47
|
+
|
48
|
+
pg_version = pg_conn.exec('SELECT version()')
|
49
|
+
puts "Testing with Postgres version: #{pg_version.getvalue(0, 0)}"
|
50
|
+
puts "Testing with ActiveRecord #{ActiveRecord::VERSION::STRING}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def teardown_test_database(pg_conn, database_name)
|
54
|
+
pg_conn.exec("DROP DATABASE IF EXISTS #{database_name}")
|
55
|
+
end
|
37
56
|
|
38
57
|
RSpec.configure do |config|
|
39
58
|
config.order = 'random'
|
40
59
|
|
41
60
|
config.before(:suite) do
|
42
|
-
|
43
|
-
|
44
|
-
|
61
|
+
PG::Connection.open("#{database_url}#{admin_database_name}") do |connection|
|
62
|
+
setup_test_database(connection, DATABASE_NAME)
|
63
|
+
end
|
45
64
|
|
46
|
-
|
47
|
-
puts "Testing with Postgres version: #{pg_version.strip}"
|
48
|
-
puts "Testing with ActiveRecord #{ActiveRecord::VERSION::STRING}"
|
65
|
+
ActiveRecord::Base.establish_connection("#{database_url}/#{DATABASE_NAME}")
|
49
66
|
|
50
|
-
database_url = "postgres://#{database_host}:#{database_port}/#{database_name}"
|
51
|
-
puts "Using database #{database_url}"
|
52
|
-
ActiveRecord::Base.establish_connection(database_url)
|
53
67
|
require 'db/schema'
|
54
|
-
DatabaseCleaner.clean_with(:truncation)
|
55
68
|
end
|
56
69
|
|
57
|
-
config.
|
58
|
-
|
70
|
+
config.after(:suite) do
|
71
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
72
|
+
|
73
|
+
PG::Connection.open("#{database_url}#{admin_database_name}") do |connection|
|
74
|
+
teardown_test_database(connection, DATABASE_NAME)
|
75
|
+
end
|
59
76
|
end
|
60
77
|
|
61
|
-
config.before do
|
78
|
+
config.before do |example|
|
79
|
+
DatabaseCleaner.strategy = example.metadata.fetch(:cleaner_strategy, :transaction)
|
62
80
|
DatabaseCleaner.start
|
63
81
|
end
|
64
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_heartbeat_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: delayed_job
|
@@ -44,20 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6.1'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '7.
|
50
|
+
version: '7.3'
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '6.1'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '7.
|
60
|
+
version: '7.3'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: appraisal
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,14 +176,14 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: 1.
|
179
|
+
version: 1.59.1
|
180
180
|
type: :development
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: 1.
|
186
|
+
version: 1.59.1
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: simplecov
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,9 +232,10 @@ files:
|
|
232
232
|
- Rakefile
|
233
233
|
- bin/setup
|
234
234
|
- delayed_job_heartbeat_plugin.gemspec
|
235
|
-
- gemfiles/rails_6.0.gemfile
|
236
235
|
- gemfiles/rails_6.1.gemfile
|
237
236
|
- gemfiles/rails_7.0.gemfile
|
237
|
+
- gemfiles/rails_7.1.gemfile
|
238
|
+
- gemfiles/rails_7.2.gemfile
|
238
239
|
- lib/delayed/heartbeat.rb
|
239
240
|
- lib/delayed/heartbeat/compatibility.rb
|
240
241
|
- lib/delayed/heartbeat/configuration.rb
|
@@ -271,14 +272,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
272
|
requirements:
|
272
273
|
- - ">="
|
273
274
|
- !ruby/object:Gem::Version
|
274
|
-
version: '
|
275
|
+
version: '3.1'
|
275
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
277
|
requirements:
|
277
278
|
- - ">="
|
278
279
|
- !ruby/object:Gem::Version
|
279
280
|
version: '0'
|
280
281
|
requirements: []
|
281
|
-
rubygems_version: 3.
|
282
|
+
rubygems_version: 3.3.26
|
282
283
|
signing_key:
|
283
284
|
specification_version: 4
|
284
285
|
summary: Delayed::Job plugin to unlock jobs from dead workers
|