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/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, ThrottleEnumerator
Constant Summary collapse
- IntegrationLoadError =
Class.new(StandardError)
- INTEGRATIONS =
[:resque, :sidekiq]
- VERSION =
"1.3.5"
Instance Attribute Summary collapse
-
#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.
-
#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
#enumerator_builder ⇒ Object
Set if you want to use your own enumerator builder instead of default EnumeratorBuilder.
36 37 38 |
# File 'lib/job-iteration.rb', line 36 def enumerator_builder @enumerator_builder end |
#interruption_adapter ⇒ Object
Used internally for hooking into job processing frameworks like Sidekiq and Resque.
24 25 26 |
# File 'lib/job-iteration.rb', line 24 def interruption_adapter @interruption_adapter 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.
21 22 23 |
# File 'lib/job-iteration.rb', line 21 def max_job_runtime @max_job_runtime end |
Class Method Details
.load_integration(integration) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/job-iteration.rb', line 54 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
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/job-iteration.rb', line 40 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 |
Instance Method Details
#load_integration(integration) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/job-iteration.rb', line 54 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
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/job-iteration.rb', line 40 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 |