Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add job-iteration integration #1217

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gemspec

gem 'activerecord-jdbcpostgresql-adapter', platforms: [:jruby]
gem 'appraisal'
gem 'job-iteration'
gem 'matrix'
gem 'nokogiri'
gem 'pg', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ GEM
reline (>= 0.3.8)
jar-dependencies (0.4.1)
jdbc-postgres (42.6.0)
job-iteration (1.4.1)
activejob (>= 5.2)
json (2.6.3)
json (2.6.3-java)
kramdown (2.4.0)
Expand Down Expand Up @@ -514,6 +516,7 @@ DEPENDENCIES
github_changelog_generator
good_job!
i18n-tasks
job-iteration
kramdown
kramdown-parser-gfm
matrix
Expand Down
2 changes: 2 additions & 0 deletions lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
require "good_job/shared_executor"
require "good_job/systemd_service"

require "job_iteration/integrations/good_job"

# GoodJob is a multithreaded, Postgres-based, ActiveJob backend for Ruby on Rails.
#
# +GoodJob+ is the top-level namespace and exposes configuration attributes.
Expand Down
21 changes: 21 additions & 0 deletions lib/job_iteration/integrations/good_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

begin
require "job-iteration"

module JobIteration
module Integrations
module GoodJob
class << self
def call
::GoodJob.shutdown?
end
end
end
end
end

JobIteration.interruption_adapter = JobIteration::Integrations::GoodJob
rescue LoadError
# job-iteration is not present
end
27 changes: 27 additions & 0 deletions spec/lib/job_iteration/integrations/good_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require 'rails_helper'

describe JobIteration::Integrations::GoodJob do
it 'sets up the interruption adapter' do
expect(JobIteration.interruption_adapter).to eq(described_class)
end

describe '.call' do
context 'when GoodJob is shutting down' do
before { allow(GoodJob).to receive(:shutdown?).and_return(true) }

it 'returns true' do
expect(described_class.call).to be(true)
end
end

context 'when GoodJob is not shutting down' do
before { allow(GoodJob).to receive(:shutdown?).and_return(false) }

it 'returns false' do
expect(described_class.call).to be(false)
end
end
end
end