Module: JobIteration
- Extended by:
- JobIteration
- Included in:
- JobIteration
- Defined in:
- lib/job-iteration/throttle_enumerator.rb,
lib/job-iteration.rb,
lib/job-iteration/version.rb,
lib/job-iteration/iteration.rb,
lib/job-iteration/test_helper.rb,
lib/job-iteration/csv_enumerator.rb,
lib/job-iteration/log_subscriber.rb,
lib/job-iteration/nested_enumerator.rb,
lib/job-iteration/enumerator_builder.rb,
lib/job-iteration/integrations/resque.rb,
lib/job-iteration/active_record_cursor.rb,
lib/job-iteration/integrations/sidekiq.rb,
lib/job-iteration/active_record_enumerator.rb,
lib/job-iteration/active_record_batch_enumerator.rb
Overview
typed: true frozen_string_literal: true
Defined Under Namespace
Modules: Iteration, TestHelper Classes: ActiveRecordBatchEnumerator, ActiveRecordCursor, ActiveRecordEnumerator, CsvEnumerator, EnumeratorBuilder, LogSubscriber, ThrottleEnumerator
Constant Summary collapse
- IntegrationLoadError =
Class.new(StandardError)
- INTEGRATIONS =
[:resque, :sidekiq]
- VERSION =
"1.4.1"
Instance Attribute Summary collapse
-
#default_retry_backoff ⇒ Object
Configures a delay duration to wait before resuming an interrupted job.
-
#enumerator_builder ⇒ Object
Set if you want to use your own enumerator builder instead of default EnumeratorBuilder.
-
#interruption_adapter ⇒ Object
Used internally for hooking into job processing frameworks like Sidekiq and Resque.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
-
#max_job_runtime ⇒ Object
Use this to always interrupt the job after it's been running for more than N seconds.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#default_retry_backoff ⇒ Object
Configures a delay duration to wait before resuming an interrupted job. Defaults to nil which means interrupted jobs will be retried immediately. This value will be ignored when an interruption is raised by a throttle enumerator, where the throttle backoff value will take precedence over this setting.
50 51 52 |
# File 'lib/job-iteration.rb', line 50 def default_retry_backoff @default_retry_backoff end |
#enumerator_builder ⇒ Object
Set if you want to use your own enumerator builder instead of default EnumeratorBuilder.
65 66 67 |
# File 'lib/job-iteration.rb', line 65 def enumerator_builder @enumerator_builder end |
#interruption_adapter ⇒ Object
Used internally for hooking into job processing frameworks like Sidekiq and Resque.
53 54 55 |
# File 'lib/job-iteration.rb', line 53 def interruption_adapter @interruption_adapter end |
#logger=(value) ⇒ Object (writeonly)
Sets the attribute logger
16 17 18 |
# File 'lib/job-iteration.rb', line 16 def logger=(value) @logger = value end |
#max_job_runtime ⇒ Object
Use this to always interrupt the job after it's been running for more than N seconds. This setting will make it to always interrupt a job after it's been iterating for 5 minutes. Defaults to nil which means that jobs will not be interrupted except on termination signal.
This setting can be further reduced (but not increased) by using the inheritable per-class job_iteration_max_job_runtime setting.
40 41 42 |
# File 'lib/job-iteration.rb', line 40 def max_job_runtime @max_job_runtime end |
Class Method Details
.load_integration(integration) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/job-iteration.rb', line 83 def load_integration(integration) unless INTEGRATIONS.include?(integration) raise IntegrationLoadError, "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(", ")}" end require_relative "./job-iteration/integrations/#{integration}" end |
.load_integrations ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/job-iteration.rb', line 69 def load_integrations loaded = nil INTEGRATIONS.each do |integration| load_integration(integration) if loaded raise IntegrationLoadError, "#{loaded} integration has already been loaded, but #{integration} is also available. " \ "Iteration will only work with one integration." end loaded = integration rescue LoadError end end |
.logger ⇒ Object
19 20 21 |
# File 'lib/job-iteration.rb', line 19 def logger @logger || ActiveJob::Base.logger end |
Instance Method Details
#load_integration(integration) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/job-iteration.rb', line 83 def load_integration(integration) unless INTEGRATIONS.include?(integration) raise IntegrationLoadError, "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(", ")}" end require_relative "./job-iteration/integrations/#{integration}" end |
#load_integrations ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/job-iteration.rb', line 69 def load_integrations loaded = nil INTEGRATIONS.each do |integration| load_integration(integration) if loaded raise IntegrationLoadError, "#{loaded} integration has already been loaded, but #{integration} is also available. " \ "Iteration will only work with one integration." end loaded = integration rescue LoadError end end |