Skip to content
Open
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nil

### Features

nil
- Add interruption adapter for [Shoryuken](https://github.com/ruby-shoryuken/shoryuken).

### Bug fixes

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ end
gem "sidekiq", sidekiq_version
gem "resque", resque_version
gem "delayed_job"
gem "shoryuken"
gem "connection_pool", connection_pool_version

if defined?(@rails_gems_requirements) && @rails_gems_requirements
Expand Down
22 changes: 22 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ GEM
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.3)
aws-eventstream (1.4.0)
aws-partitions (1.1261.0)
aws-sdk-core (3.252.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-sqs (1.116.0)
aws-sdk-core (~> 3, >= 3.248.0)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.12.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (3.3.1)
Expand All @@ -77,6 +92,7 @@ GEM
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
json (2.16.0)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
Expand Down Expand Up @@ -196,6 +212,11 @@ GEM
rubydex (0.1.0.beta13-x86_64-darwin)
rubydex (0.1.0.beta13-x86_64-linux)
securerandom (0.4.1)
shoryuken (7.0.2)
aws-sdk-sqs (>= 1.66.0)
concurrent-ruby
thor
zeitwerk (~> 2.6)
sidekiq (8.0.10)
connection_pool (>= 2.5.0)
json (>= 2.9.0)
Expand Down Expand Up @@ -275,6 +296,7 @@ DEPENDENCIES
redis
resque (>= 3.0.0)
rubocop-shopify
shoryuken
sidekiq (>= 8.0.9)
sorbet-runtime (>= 0.6.12698)
tapioca (>= 0.19.1)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Job-iteration currently supports the following queue adapters (in order of imple
- [Solid Queue](https://github.com/rails/solid_queue)
- [Amazon SQS](https://github.com/aws/aws-activejob-sqs-ruby)
- [Delayed::Job](https://github.com/collectiveidea/delayed_job)
- [Shoryuken](https://github.com/ruby-shoryuken/shoryuken)

It supports the following platforms:

Expand Down
2 changes: 1 addition & 1 deletion lib/job-iteration/interruption_adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module JobIteration
module InterruptionAdapters
BUNDLED_ADAPTERS = [:delayed_job, :good_job, :resque, :sidekiq, :solid_queue, :sqs].freeze # @api private
BUNDLED_ADAPTERS = [:delayed_job, :good_job, :resque, :shoryuken, :sidekiq, :solid_queue, :sqs].freeze # @api private

class << self
# Returns adapter for specified name.
Expand Down
39 changes: 39 additions & 0 deletions lib/job-iteration/interruption_adapters/shoryuken_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

begin
require "shoryuken"
rescue LoadError
# Shoryuken is not available, no need to load the adapter
return
end

begin
# Lifecycle event registration (Shoryuken.configure_server / config.on) was
# introduced in Shoryuken 2.0.2.
gem("shoryuken", ">= 2.0.2")
rescue Gem::LoadError
warn("job-iteration's interruption adapter for Shoryuken requires Shoryuken 2.0.2 or newer")
return
end

module JobIteration
module InterruptionAdapters
module ShoryukenAdapter
class << self
attr_accessor :stopping

def call
stopping
end
end

Shoryuken.configure_server do |config|
config.on(:shutdown) do
ShoryukenAdapter.stopping = true
end
end
end

register(:shoryuken, ShoryukenAdapter)
end
end
Loading