Module: JobIteration

Extended by:
JobIteration
Included in:
JobIteration
Defined in:
lib/job-iteration/throttle_enumerator.rb,
lib/job-iteration.rb,
lib/job-iteration/railtie.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/active_record_cursor.rb,
lib/job-iteration/interruption_adapters.rb,
lib/job-iteration/active_record_enumerator.rb,
lib/job-iteration/active_record_batch_enumerator.rb,
lib/job-iteration/interruption_adapters/sqs_adapter.rb,
lib/job-iteration/interruption_adapters/null_adapter.rb,
lib/job-iteration/interruption_adapters/resque_adapter.rb,
lib/job-iteration/interruption_adapters/sidekiq_adapter.rb,
lib/job-iteration/interruption_adapters/good_job_adapter.rb,
lib/job-iteration/interruption_adapters/solid_queue_adapter.rb

Overview

This adapter never interrupts.

Defined Under Namespace

Modules: InterruptionAdapters, Iteration, TestHelper Classes: ActiveRecordBatchEnumerator, ActiveRecordCursor, ActiveRecordEnumerator, CsvEnumerator, EnumeratorBuilder, LogSubscriber, Railtie, ThrottleEnumerator

Constant Summary collapse

Deprecation =
ActiveSupport::Deprecation.new("2.0", "JobIteration")
VERSION =
"1.8.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#default_retry_backoffObject

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.

Examples:


JobIteration.default_retry_backoff = 10.seconds


58
59
60
# File 'lib/job-iteration.rb', line 58

def default_retry_backoff
  @default_retry_backoff
end

#enumerator_builderObject

Set if you want to use your own enumerator builder instead of default EnumeratorBuilder.

Examples:


class MyOwnBuilder < JobIteration::EnumeratorBuilder
  # ...
end

JobIteration.enumerator_builder = MyOwnBuilder


84
85
86
# File 'lib/job-iteration.rb', line 84

def enumerator_builder
  @enumerator_builder
end

#interruption_adapterObject

Returns the value of attribute interruption_adapter.



60
61
62
# File 'lib/job-iteration.rb', line 60

def interruption_adapter
  @interruption_adapter
end

#logger=(value) ⇒ Object (writeonly)

Sets the attribute logger

Parameters:

  • value

    the value to set the attribute logger to.



16
17
18
# File 'lib/job-iteration.rb', line 16

def logger=(value)
  @logger = value
end

#max_job_runtimeObject

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 overriden by using the inheritable per-class job_iteration_max_job_runtime setting. At runtime, the lower of the two will be used. Note that if a sub-class overrides its parent's setting, only the global and sub-class setting will be considered, not the parent's.

Examples:


JobIteration.max_job_runtime = 5.minutes

class MyJob < ActiveJob::Base
  include JobIteration::Iteration
  self.job_iteration_max_job_runtime = 1.minute
  # ...

class ChildJob < MyJob
  self.job_iteration_max_job_runtime = 3.minutes # MyJob's 1.minute will be discarded.
  # ...


48
49
50
# File 'lib/job-iteration.rb', line 48

def max_job_runtime
  @max_job_runtime
end

Class Method Details

.loggerObject



19
20
21
# File 'lib/job-iteration.rb', line 19

def logger
  @logger || ActiveJob::Base.logger
end

.register_interruption_adapter(adapter_name, adapter) ⇒ Object



72
73
74
# File 'lib/job-iteration.rb', line 72

def register_interruption_adapter(adapter_name, adapter)
  InterruptionAdapters.register(adapter_name, adapter)
end

Instance Method Details

#register_interruption_adapter(adapter_name, adapter) ⇒ Object



72
73
74
# File 'lib/job-iteration.rb', line 72

def register_interruption_adapter(adapter_name, adapter)
  InterruptionAdapters.register(adapter_name, adapter)
end