-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for selectively choosing deduplication keys. (#102)
- Loading branch information
Showing
11 changed files
with
183 additions
and
9 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
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
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Aws | ||
module Rails | ||
# SQS ActiveJob modules | ||
module SqsActiveJob | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
class_attribute :excluded_deduplication_keys | ||
end | ||
|
||
# class methods for SQS ActiveJob. | ||
module ClassMethods | ||
def deduplicate_without(*keys) | ||
self.excluded_deduplication_keys = keys.map(&:to_s) | ['job_id'] | ||
end | ||
end | ||
end | ||
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
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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
require_relative 'test_job' | ||
|
||
module Aws | ||
module Rails | ||
module SqsActiveJob | ||
describe 'ClassMethods' do | ||
describe '.deduplicate_without' do | ||
let(:keys) { %w[job_id job_class queue_name] } | ||
let(:expected_keys) { keys.map(&:to_s) | ['job_id'] } | ||
|
||
it 'excluded deduplication keys set successfully' do | ||
expect(TestJobWithDedupKeys.deduplicate_without(*keys)).to contain_exactly(*expected_keys) | ||
end | ||
|
||
it 'excluded deduplication keys set successfully and job_id is added' do | ||
keys.delete(:job_id) | ||
expect(TestJobWithDedupKeys.deduplicate_without(*keys)).to contain_exactly(*expected_keys) | ||
end | ||
end | ||
end | ||
end | ||
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