Class: ActiveJob::Uniqueness::LockKey
- Inherits:
-
Object
- Object
- ActiveJob::Uniqueness::LockKey
- Defined in:
- lib/active_job/uniqueness/lock_key.rb
Constant Summary collapse
- FALLBACK_ARGUMENTS_STRING =
'no_arguments'
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#job_class_name ⇒ Object
readonly
Returns the value of attribute job_class_name.
Instance Method Summary collapse
-
#initialize(job_class_name: nil, arguments: nil) ⇒ LockKey
constructor
A new instance of LockKey.
- #lock_key ⇒ Object
-
#runtime_lock_key ⇒ Object
used only by :until_and_while_executing strategy.
- #wildcard_key ⇒ Object
Constructor Details
#initialize(job_class_name: nil, arguments: nil) ⇒ LockKey
Returns a new instance of LockKey.
14 15 16 17 18 19 20 21 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 14 def initialize(job_class_name: nil, arguments: nil) if arguments.present? && job_class_name.blank? raise ArgumentError, 'job_class_name is required if arguments given' end @job_class_name = job_class_name @arguments = arguments || [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
12 13 14 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 12 def arguments @arguments end |
#job_class_name ⇒ Object (readonly)
Returns the value of attribute job_class_name.
12 13 14 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 12 def job_class_name @job_class_name end |
Instance Method Details
#lock_key ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 23 def lock_key [ lock_prefix, normalized_job_class_name, arguments_key_part ].join(':') end |
#runtime_lock_key ⇒ Object
used only by :until_and_while_executing strategy
32 33 34 35 36 37 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 32 def runtime_lock_key [ lock_key, 'runtime' ].join(':') end |
#wildcard_key ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/active_job/uniqueness/lock_key.rb', line 39 def wildcard_key [ lock_prefix, normalized_job_class_name, arguments.any? ? "#{arguments_key_part}*" : '*' ].compact.join(':') end |