-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from kakubin/interruption_adapter_aws_activej…
…ob_sqs Add interruption adapter for aws-activejob-sqs
- Loading branch information
Showing
4 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
begin | ||
require "aws-activejob-sqs" | ||
rescue LoadError | ||
# Aws::ActiveJob::SQS is not available, no need to load the adapter | ||
return | ||
end | ||
|
||
begin | ||
# Aws::ActiveJob::SQS.on_worker_stop was introduced in Aws::ActiveJob::SQS 0.1.1 | ||
gem("aws-activejob-sqs", ">= 0.1.1") | ||
rescue Gem::LoadError | ||
warn("job-iteration's interruption adapter for SQS requires aws-activejob-sqs 0.1.1 or newer") | ||
return | ||
end | ||
|
||
module JobIteration | ||
module InterruptionAdapters | ||
module SqsAdapter | ||
class << self | ||
attr_accessor :stopping | ||
|
||
def call | ||
stopping | ||
end | ||
end | ||
|
||
Aws::ActiveJob::SQS.on_worker_stop do | ||
SqsAdapter.stopping = true | ||
end | ||
end | ||
|
||
register(:sqs, SqsAdapter) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters