delayed_job_heartbeat_plugin 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1be4392005e897fdb23c9ee24ba53926bec7b0db85732127b7a88ebc570cdc8
4
- data.tar.gz: aaf73ae4a764f1ad1b17f419388b9ed950ef5c5d828af252988117a95c34c56a
3
+ metadata.gz: 4e345f76bdcd070b600dfab6df2b3eb8605b9c782f9e1b889c737f9e928fa3d3
4
+ data.tar.gz: 9d1a29cf20de158f54c7cb1c56eb6ed39e18112e21af8021c62a2eb911220598
5
5
  SHA512:
6
- metadata.gz: 46ac706430681a541a6c4c4fe91222183357c0c4cf1fe33db2ebcf422560080a95761e1f1646d376c12c1d4e01c3f4b531aaa4932cdc56940b591a05171ddc3f
7
- data.tar.gz: 46bacc4d2ee52f933763625f16ffece66cb24e427a708dcaa89a241ba65e4102b86512e85884ea343762ad092d04bd5e595032289bbc1c38402bba34b5a99f0f
6
+ metadata.gz: b67e3d0bed56aeb692398b6b3bb83cdb11faafd8fdb1f392961ffe61e97537f7918b42927e58f561e7d8b8c643ea6c368fa32bd937d0d8bd483f588d185d54b8
7
+ data.tar.gz: 409f328c1244d38bc9f161dbfd28e6169b626b0831a896716090b7d05357e3d43688cf448c22494bd2a154a399c5e6c28a4eefc962c606fcf1f639adb055694e
data/.circleci/config.yml CHANGED
@@ -2,14 +2,14 @@ version: 2.1
2
2
  jobs:
3
3
  lint:
4
4
  docker:
5
- - image: salsify/ruby_ci:2.5.8
5
+ - image: cimg/ruby:3.1.6
6
6
  working_directory: ~/delayed_job_heartbeat_plugin
7
7
  steps:
8
8
  - checkout
9
9
  - restore_cache:
10
10
  keys:
11
- - v1-gems-ruby-2.5.8-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v1-gems-ruby-2.5.8-
11
+ - v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v1-gems-ruby-3.1.6-
13
13
  - run:
14
14
  name: Install Gems
15
15
  command: |
@@ -18,7 +18,7 @@ jobs:
18
18
  bundle clean
19
19
  fi
20
20
  - save_cache:
21
- key: v1-gems-ruby-2.5.8-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
21
+ key: v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
22
22
  paths:
23
23
  - "vendor/bundle"
24
24
  - "gemfiles/vendor/bundle"
@@ -32,13 +32,19 @@ jobs:
32
32
  ruby_version:
33
33
  type: string
34
34
  docker:
35
- - image: salsify/ruby_ci:<< parameters.ruby_version >>
36
- - image: circleci/postgres:9.6
35
+ - image: cimg/ruby:<< parameters.ruby_version >>
36
+ environment:
37
+ DB_USER: "circleci"
38
+ - image: cimg/postgres:12.9
37
39
  environment:
38
40
  POSTGRES_USER: "circleci"
39
41
  POSTGRES_DB: "circle_test"
40
42
  POSTGRES_HOST_AUTH_METHOD: "trust"
41
43
  environment:
44
+ RACK_ENV: "test"
45
+ RAILS_ENV: "test"
46
+ DB_USER: "circleci"
47
+ ADMIN_DB_NAME: "circle_test"
42
48
  CIRCLE_TEST_REPORTS: "test-results"
43
49
  BUNDLE_GEMFILE: << parameters.gemfile >>
44
50
  working_directory: ~/delayed_job_heartbeat_plugin
@@ -65,7 +71,7 @@ jobs:
65
71
  command: dockerize -wait tcp://localhost:5432 -timeout 60s
66
72
  - run:
67
73
  name: Wait for Database User
68
- command: t=60; 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;
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;
69
75
  - run:
70
76
  name: Run Tests
71
77
  command: |
@@ -79,15 +85,12 @@ workflows:
79
85
  - test:
80
86
  matrix:
81
87
  parameters:
82
- ruby_version:
83
- - "2.5.8"
84
- - "2.6.5"
85
- - "2.7.2"
86
- - "3.0.0"
87
88
  gemfile:
88
- - "gemfiles/rails_5.2.gemfile"
89
- - "gemfiles/rails_6.0.gemfile"
90
- - "gemfiles/rails_6.1.gemfile"
91
- exclude:
92
- - ruby_version: "3.0.0"
93
- gemfile: "gemfiles/rails_5.2.gemfile"
89
+ - gemfiles/rails_6.1.gemfile
90
+ - gemfiles/rails_7.0.gemfile
91
+ - gemfiles/rails_7.1.gemfile
92
+ - gemfiles/rails_7.2.gemfile
93
+ ruby_version:
94
+ - 3.1.6
95
+ - 3.2.5
96
+ - 3.3.4
@@ -0,0 +1 @@
1
+ * @salsify/pim-core-backend
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  salsify_rubocop: conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 3.1
6
6
  Exclude:
7
7
  - 'vendor/**/*'
8
- - 'gemfiles/vendor/**/*'
8
+ - 'gemfiles/**/*'
data/Appraisals CHANGED
@@ -1,16 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-5.2' do
4
- gem 'activerecord', '5.2.5'
5
- gem 'activesupport', '5.2.5'
3
+ appraise 'rails-6.1' do
4
+ gem 'activerecord', '~> 6.1.5'
5
+ gem 'activesupport', '~> 6.1.5'
6
6
  end
7
7
 
8
- appraise 'rails-6.0' do
9
- gem 'activerecord', '6.0.3.6'
10
- gem 'activesupport', '6.0.3.6'
8
+ appraise 'rails-7.0' do
9
+ gem 'activerecord', '~> 7.0.2'
10
+ gem 'activesupport', '~> 7.0.2'
11
11
  end
12
12
 
13
- appraise 'rails-6.1' do
14
- gem 'activerecord', '6.1.3.1'
15
- gem 'activesupport', '6.1.3.1'
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'
16
21
  end
data/CHANGELOG.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Changelog
2
2
 
3
- ### 0.4.0
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
+
12
+ - Drop support for ruby < 2.7
13
+ - Add support for ruby 3.1
14
+ - Drop Rails 5.2
15
+ - Add Rails 7.0
16
+
17
+ ## 0.4.0
18
+
4
19
  - Use frozen string literals.
5
20
 
6
- ### 0.3.0
7
- * Drop support for Ruby < 2.5.
8
- * Drop support for Rails < 5.2.
9
- * Bugfix for rails version in generated migration files
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
10
28
 
11
- ### 0.2.0
12
- * 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
@@ -14,16 +14,23 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/salsify/delayed_job_heartbeat_plugin'
15
15
  spec.license = 'MIT'
16
16
 
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+ spec.metadata['rubygems_mfa_required'] = 'true'
20
+ else
21
+ raise 'RubyGems 2.0 or newer is required to set allowed_push_host.'
22
+ end
23
+
17
24
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
25
  spec.test_files = Dir.glob('spec/**/*')
19
26
  spec.require_paths = ['lib']
20
27
 
21
- spec.required_ruby_version = '>= 2.5'
28
+ spec.required_ruby_version = '>= 3.1'
22
29
 
23
30
  spec.add_dependency 'delayed_job', '>= 4.1.0'
24
31
  spec.add_dependency 'delayed_job_active_record', '>= 4.1.0'
25
32
 
26
- spec.add_development_dependency 'activerecord', ['>= 5.2', '< 7']
33
+ spec.add_development_dependency 'activerecord', ['>= 6.1', '< 7.3']
27
34
  spec.add_development_dependency 'appraisal'
28
35
  spec.add_development_dependency 'bundler'
29
36
  spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
@@ -32,7 +39,7 @@ Gem::Specification.new do |spec|
32
39
  spec.add_development_dependency 'rake', '~> 13.0'
33
40
  spec.add_development_dependency 'rspec', '~> 3'
34
41
  spec.add_development_dependency 'rspec_junit_formatter'
35
- spec.add_development_dependency 'salsify_rubocop', '~> 1.0.2'
42
+ spec.add_development_dependency 'salsify_rubocop', '~> 1.59.1'
36
43
  spec.add_development_dependency 'simplecov'
37
44
  spec.add_development_dependency 'timecop'
38
45
  end
@@ -1,10 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
1
  # This file was generated by Appraisal
4
2
 
5
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
6
4
 
7
- gem 'activerecord', '6.1.3.1'
8
- gem 'activesupport', '6.1.3.1'
5
+ gem "activerecord", "~> 6.1.5"
6
+ gem "activesupport", "~> 6.1.5"
9
7
 
10
- gemspec path: '../'
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.0.2"
6
+ gem "activesupport", "~> 7.0.2"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.1.3"
6
+ gem "activesupport", "~> 7.1.3"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.2.0"
6
+ gem "activesupport", "~> 7.2.0"
7
+
8
+ gemspec path: "../"
@@ -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.to_s if verbose? && results.present?
19
+ puts results if verbose? && results.present?
20
20
  end
21
21
 
22
22
  def verbose?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Delayed
4
4
  module Heartbeat
5
- VERSION = '0.4.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -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
- # Note: The built-in Delayed::Plugins::ClearLocks will unlock the jobs for us
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
- payload_object: TestJobWithCallbacks.new) do |job|
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
- database_name = 'delayed_job_heartbeat_plugin_test'
35
- database_host = ENV.fetch('PGHOST', 'localhost')
36
- database_port = ENV.fetch('PGPORT', 5432)
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
- db_connection_args = "--host #{database_host} --port #{database_port}"
43
- `dropdb #{db_connection_args} --if-exists #{database_name} 2> /dev/null`
44
- `createdb #{db_connection_args} #{database_name}`
61
+ PG::Connection.open("#{database_url}#{admin_database_name}") do |connection|
62
+ setup_test_database(connection, DATABASE_NAME)
63
+ end
45
64
 
46
- pg_version = `psql #{db_connection_args} --dbname #{database_name} --tuples-only --command "select version()";`
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.before do |example|
58
- DatabaseCleaner.strategy = example.metadata.fetch(:cleaner_strategy, :transaction)
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.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
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: '5.2'
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: '5.2'
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.0.2
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.0.2
186
+ version: 1.59.1
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: simplecov
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +212,7 @@ dependencies:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
- description:
215
+ description:
216
216
  email:
217
217
  - jturkel@salsify.com
218
218
  executables: []
@@ -220,6 +220,7 @@ extensions: []
220
220
  extra_rdoc_files: []
221
221
  files:
222
222
  - ".circleci/config.yml"
223
+ - ".github/CODEOWNERS"
223
224
  - ".gitignore"
224
225
  - ".rspec"
225
226
  - ".rubocop.yml"
@@ -231,9 +232,10 @@ files:
231
232
  - Rakefile
232
233
  - bin/setup
233
234
  - delayed_job_heartbeat_plugin.gemspec
234
- - gemfiles/rails_5.2.gemfile
235
- - gemfiles/rails_6.0.gemfile
236
235
  - gemfiles/rails_6.1.gemfile
236
+ - gemfiles/rails_7.0.gemfile
237
+ - gemfiles/rails_7.1.gemfile
238
+ - gemfiles/rails_7.2.gemfile
237
239
  - lib/delayed/heartbeat.rb
238
240
  - lib/delayed/heartbeat/compatibility.rb
239
241
  - lib/delayed/heartbeat/configuration.rb
@@ -259,8 +261,10 @@ files:
259
261
  homepage: https://github.com/salsify/delayed_job_heartbeat_plugin
260
262
  licenses:
261
263
  - MIT
262
- metadata: {}
263
- post_install_message:
264
+ metadata:
265
+ allowed_push_host: https://rubygems.org
266
+ rubygems_mfa_required: 'true'
267
+ post_install_message:
264
268
  rdoc_options: []
265
269
  require_paths:
266
270
  - lib
@@ -268,24 +272,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
268
272
  requirements:
269
273
  - - ">="
270
274
  - !ruby/object:Gem::Version
271
- version: '2.5'
275
+ version: '3.1'
272
276
  required_rubygems_version: !ruby/object:Gem::Requirement
273
277
  requirements:
274
278
  - - ">="
275
279
  - !ruby/object:Gem::Version
276
280
  version: '0'
277
281
  requirements: []
278
- rubygems_version: 3.1.4
279
- signing_key:
282
+ rubygems_version: 3.3.26
283
+ signing_key:
280
284
  specification_version: 4
281
285
  summary: Delayed::Job plugin to unlock jobs from dead workers
282
286
  test_files:
287
+ - spec/db/schema.rb
288
+ - spec/delayed/heartbeat/delete_worker_results_spec.rb
289
+ - spec/delayed/heartbeat/worker_heartbeat_spec.rb
290
+ - spec/delayed/heartbeat_spec.rb
283
291
  - spec/spec_helper.rb
284
292
  - spec/support/destroyed_model.rb
293
+ - spec/support/test_job.rb
285
294
  - spec/support/test_job_with_callbacks.rb
286
295
  - spec/support/wait.rb
287
- - spec/support/test_job.rb
288
- - spec/delayed/heartbeat_spec.rb
289
- - spec/delayed/heartbeat/worker_heartbeat_spec.rb
290
- - spec/delayed/heartbeat/delete_worker_results_spec.rb
291
- - spec/db/schema.rb
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '5.2.5'
8
- gem 'activesupport', '5.2.5'
9
-
10
- gemspec path: '../'
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '6.0.3.6'
8
- gem 'activesupport', '6.0.3.6'
9
-
10
- gemspec path: '../'