Module: GoodJob::ActiveJobExtensions::Concurrency
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/good_job/active_job_extensions/concurrency.rb
Defined Under Namespace
Modules: Prepends Classes: ConcurrencyExceededError
Constant Summary collapse
- VALID_TYPES =
[String, Symbol, Numeric, Date, Time, TrueClass, FalseClass, NilClass].freeze
- ThrottleExceededError =
Class.new(ConcurrencyExceededError)
Instance Method Summary collapse
-
#_good_job_concurrency_key ⇒ Object
Generates the concurrency key from the configuration.
-
#_good_job_default_concurrency_key ⇒ String
Generates the default concurrency key when the configuration doesn’t provide one.
-
#good_job_concurrency_key ⇒ Object
Existing or dynamically generated concurrency key.
Instance Method Details
#_good_job_concurrency_key ⇒ Object
Generates the concurrency key from the configuration
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/good_job/active_job_extensions/concurrency.rb', line 202 def _good_job_concurrency_key return _good_job_default_concurrency_key unless self.class.good_job_concurrency_config.key?(:key) key = self.class.good_job_concurrency_config[:key] return if key.blank? key = instance_exec(&key) if key.respond_to?(:call) raise TypeError, "Concurrency key must be a String; was a #{key.class}" unless VALID_TYPES.any? { |type| key.is_a?(type) } key end |
#_good_job_default_concurrency_key ⇒ String
Generates the default concurrency key when the configuration doesn’t provide one
216 217 218 |
# File 'lib/good_job/active_job_extensions/concurrency.rb', line 216 def _good_job_default_concurrency_key self.class.name.to_s end |
#good_job_concurrency_key ⇒ Object
Existing or dynamically generated concurrency key
196 197 198 |
# File 'lib/good_job/active_job_extensions/concurrency.rb', line 196 def good_job_concurrency_key @good_job_concurrency_key || _good_job_concurrency_key end |