Class: Sidekiq::Batch::Jobs::Configuration
- Inherits:
-
Object
- Object
- Sidekiq::Batch::Jobs::Configuration
- Defined in:
- lib/sidekiq/batch/jobs/configuration.rb
Overview
Everything a host can tune, through Sidekiq::Batch::Jobs.configure. An
initializer is the right place: it runs before any model is autoloaded,
which base_class_name requires.
Constant Summary collapse
- DEFAULT_BASE_CLASS_NAME =
"ActiveRecord::Base"- DEFAULT_STUCK_AFTER =
2 hours
2 * 60 * 60
- DEFAULT_RETENTION =
30 days
30 * 24 * 60 * 60
- DEFAULT_ERROR_MESSAGE_MAX =
4_000- DEFAULT_MAINTENANCE_QUEUE =
"default"- DEFAULT_FAILURE_POLICY =
:any_failure- DEFAULT_ON_ALERT =
Warn rather than stay silent: the reaper only speaks up after it has marked someone's jobs failed or re-fired a callback. Never routine.
->() { ::Sidekiq.logger.warn("[sidekiq-batch-jobs] #{}") }
Instance Attribute Summary collapse
-
#auto_install ⇒ Object
Returns the value of attribute auto_install.
-
#base_class_name ⇒ Object
Returns the value of attribute base_class_name.
-
#error_message_max ⇒ Object
In characters, not bytes.
-
#failure_policy ⇒ Object
Returns the value of attribute failure_policy.
-
#maintenance_queue ⇒ Object
Returns the value of attribute maintenance_queue.
-
#on_alert ⇒ Object
Callable taking one String, or nil to silence entirely.
-
#retention ⇒ Object
Returns the value of attribute retention.
-
#stuck_after ⇒ Object
Returns the value of attribute stuck_after.
Instance Method Summary collapse
-
#alert(message) ⇒ Object
A broken alert channel must not take down the reaper run that was trying to report through it.
-
#base_class ⇒ Object
Never memoised, so each reload of the models picks up the current object.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 31 def initialize @auto_install = true @base_class_name = DEFAULT_BASE_CLASS_NAME @stuck_after = DEFAULT_STUCK_AFTER @retention = DEFAULT_RETENTION @error_message_max = DEFAULT_ERROR_MESSAGE_MAX @maintenance_queue = DEFAULT_MAINTENANCE_QUEUE @on_alert = DEFAULT_ON_ALERT @failure_policy = FailurePolicy.normalize(DEFAULT_FAILURE_POLICY) end |
Instance Attribute Details
#auto_install ⇒ Object
Returns the value of attribute auto_install.
21 22 23 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 21 def auto_install @auto_install end |
#base_class_name ⇒ Object
Returns the value of attribute base_class_name.
29 30 31 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 29 def base_class_name @base_class_name end |
#error_message_max ⇒ Object
In characters, not bytes.
24 25 26 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 24 def @error_message_max end |
#failure_policy ⇒ Object
Returns the value of attribute failure_policy.
29 30 31 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 29 def failure_policy @failure_policy end |
#maintenance_queue ⇒ Object
Returns the value of attribute maintenance_queue.
21 22 23 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 21 def maintenance_queue @maintenance_queue end |
#on_alert ⇒ Object
Callable taking one String, or nil to silence entirely.
27 28 29 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 27 def on_alert @on_alert end |
#retention ⇒ Object
Returns the value of attribute retention.
29 30 31 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 29 def retention @retention end |
#stuck_after ⇒ Object
Returns the value of attribute stuck_after.
29 30 31 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 29 def stuck_after @stuck_after end |
Instance Method Details
#alert(message) ⇒ Object
A broken alert channel must not take down the reaper run that was trying to report through it.
76 77 78 79 80 81 82 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 76 def alert() on_alert&.call() rescue StandardError => e ::Sidekiq.logger.error( "[sidekiq-batch-jobs] on_alert raised #{e.class}: #{e.} — original message: #{}" ) end |
#base_class ⇒ Object
Never memoised, so each reload of the models picks up the current
object. const_get rather than constantize because this runs from a
model class body, where ActiveSupport may not be loaded yet.
53 54 55 |
# File 'lib/sidekiq/batch/jobs/configuration.rb', line 53 def base_class ::Object.const_get(base_class_name) end |