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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ba564b35f94921f30c324a5597705a743fd443946492b131f382282d2650c91
4
- data.tar.gz: 63947153fbcf5b303d47981cee2a21eb8f4d76298ad6bc4e8fefe18da9cabe26
3
+ metadata.gz: 4e345f76bdcd070b600dfab6df2b3eb8605b9c782f9e1b889c737f9e928fa3d3
4
+ data.tar.gz: 9d1a29cf20de158f54c7cb1c56eb6ed39e18112e21af8021c62a2eb911220598
5
5
  SHA512:
6
- metadata.gz: 25f9c2a073c041070f6f25d0b5c20a03fe60a598880a95f25478e62fca3d1c2cd046e312e4d7da4355254b86f3fc2b5551a8d35d287baff015dcde5a767dc727
7
- data.tar.gz: 6abadd87e0918dc4f0cb9f501455444b8ea81e30473913d229967d95909682d1673402267fe47c20c4d134136e09592f6607648b70320fa1f6b508dc78e70bda
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
- docker:
5
- - image: salsify/ruby_ci:2.7.6
6
- working_directory: ~/delayed_job_heartbeat_plugin
7
- steps:
8
- - checkout
9
- - restore_cache:
10
- keys:
11
- - v1-gems-ruby-2.7.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v1-gems-ruby-2.7.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-2.7.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
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
- parameters:
30
- gemfile:
31
- type: string
32
- ruby_version:
33
- type: string
34
- docker:
35
- - image: salsify/ruby_ci:<< parameters.ruby_version >>
36
- environment:
37
- DB_USER: "circleci"
38
- - image: cimg/postgres:12.7
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
- CIRCLE_TEST_REPORTS: "test-results"
47
- BUNDLE_GEMFILE: << parameters.gemfile >>
48
- working_directory: ~/delayed_job_heartbeat_plugin
49
- steps:
50
- - checkout
51
- - restore_cache:
52
- keys:
53
- - v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
54
- - v1-gems-ruby-<< parameters.ruby_version >>-
55
- - run:
56
- name: Install Gems
57
- command: |
58
- if ! bundle check --path=vendor/bundle; then
59
- bundle install --path=vendor/bundle --jobs=4 --retry=3
60
- bundle clean
61
- fi
62
- - save_cache:
63
- key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
64
- paths:
65
- - "vendor/bundle"
66
- - "gemfiles/vendor/bundle"
67
- - run:
68
- name: Wait for Database
69
- command: dockerize -wait tcp://localhost:5432 -timeout 60s
70
- - run:
71
- name: Wait for Database User
72
- 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;
73
- - run:
74
- name: Run Tests
75
- command: |
76
- bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
77
- - store_test_results:
78
- path: "test-results"
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
- - "gemfiles/rails_6.0.gemfile"
88
- - "gemfiles/rails_6.1.gemfile"
89
- - "gemfiles/rails_7.0.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
90
93
  ruby_version:
91
- - "2.7.6"
92
- - "3.0.4"
93
- - "3.1.2"
94
+ - 3.1.6
95
+ - 3.2.5
96
+ - 3.3.4
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @jturkel @will89
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.7
5
+ TargetRubyVersion: 3.1
6
6
  Exclude:
7
7
  - 'vendor/**/*'
8
8
  - 'gemfiles/**/*'
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
- ### 0.5.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
+
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
- ### 0.4.0
17
+ ## 0.4.0
18
+
10
19
  - Use frozen string literals.
11
20
 
12
- ### 0.3.0
13
- * Drop support for Ruby < 2.5.
14
- * Drop support for Rails < 5.2.
15
- * 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
16
28
 
17
- ### 0.2.0
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 = '>= 2.7'
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', ['>= 5.2', '< 7.1']
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.0.2'
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.0.4"
6
- gem "activesupport", "~> 6.0.4"
5
+ gem "activerecord", "~> 7.1.3"
6
+ gem "activesupport", "~> 7.1.3"
7
7
 
8
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.5.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.5.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: 2022-04-25 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.1'
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.1'
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
@@ -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: '2.7'
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.2.33
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