-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename remaining unique_* keys to lock_* (#475)
* Rename remaining unique_* keys to lock_* * Mandatory rubocop commit # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit. * Adds missing tests for deprecations * Mandatory rubocop commit * Mandatory reek commit
- Loading branch information
Showing
64 changed files
with
260 additions
and
219 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ class UniqueJobsError < ::RuntimeError | |
# @author Mikael Henriksson <[email protected]> | ||
class Conflict < UniqueJobsError | ||
def initialize(item) | ||
super("Item with the key: #{item[UNIQUE_DIGEST]} is already scheduled or processing") | ||
super("Item with the key: #{item[LOCK_DIGEST]} is already scheduled or processing") | ||
end | ||
end | ||
|
||
|
@@ -61,15 +61,17 @@ def initialize(lock_config) | |
# @author Mikael Henriksson <[email protected]> | ||
class InvalidUniqueArguments < UniqueJobsError | ||
def initialize(options) | ||
given = options[:given] | ||
worker_class = options[:worker_class] | ||
unique_args_method = options[:unique_args_method] | ||
uniq_args_meth = worker_class.method(unique_args_method) | ||
num_args = uniq_args_meth.arity | ||
# source_location = uniq_args_meth.source_location | ||
given = options[:given] | ||
worker_class = options[:worker_class] | ||
lock_args_method = options[:lock_args_method] | ||
lock_args_meth = worker_class.method(lock_args_method) | ||
num_args = lock_args_meth.arity | ||
source_location = lock_args_meth.source_location | ||
|
||
super( | ||
"#{worker_class}#unique_args takes #{num_args} arguments, received #{given.inspect}" | ||
"#{worker_class}##{lock_args_method} takes #{num_args} arguments, received #{given.inspect}" \ | ||
"\n\n" \ | ||
" #{source_location.join(':')}" | ||
) | ||
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
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 |
---|---|---|
|
@@ -8,6 +8,12 @@ class Lock | |
# @author Mikael Henriksson <[email protected]> | ||
# | ||
class Validator | ||
DEPRECATED_KEYS = { | ||
UNIQUE.to_sym => LOCK.to_sym, | ||
UNIQUE_ARGS.to_sym => LOCK_ARGS.to_sym, | ||
UNIQUE_PREFIX.to_sym => LOCK_PREFIX.to_sym, | ||
}.freeze | ||
|
||
# | ||
# Shorthand for `new(options).validate` | ||
# | ||
|
@@ -30,7 +36,9 @@ def self.validate(options) | |
# @param [Hash] options the sidekiq_options for the worker being validated | ||
# | ||
def initialize(options) | ||
@options = options.transform_keys(&:to_sym) | ||
@lock_config = LockConfig.new(options) | ||
handle_deprecations | ||
end | ||
|
||
# | ||
|
@@ -53,6 +61,14 @@ def validate | |
lock_config | ||
end | ||
|
||
def handle_deprecations | ||
DEPRECATED_KEYS.each do |old, new| | ||
next unless @options.key?(old) | ||
|
||
lock_config.errors[old] = "is deprecated, use `#{new}: #{@options[old]}` instead." | ||
end | ||
end | ||
|
||
# | ||
# Validates the client configuration | ||
# | ||
|
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
Oops, something went wrong.