Module: JobIteration::InterruptionAdapters

Defined in:
lib/job-iteration/interruption_adapters.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

Defined Under Namespace

Modules: GoodJobAdapter, NullAdapter, ResqueAdapter, SidekiqAdapter, SolidQueueAdapter, SqsAdapter

Constant Summary collapse

BUNDLED_ADAPTERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[:good_job, :resque, :sidekiq, :solid_queue, :sqs].freeze

Class Method Summary collapse

Class Method Details

.lookup(name) ⇒ Object

Returns adapter for specified name.

JobIteration::InterruptionAdapters.lookup(:sidekiq) # => JobIteration::InterruptionAdapters::SidekiqAdapter



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/job-iteration/interruption_adapters.rb', line 14

def lookup(name)
  registry.fetch(name.to_sym) do
    Deprecation.warn(<<~DEPRECATION_MESSAGE, caller_locations(1))
      No interruption adapter is registered for #{name.inspect}; falling back to `NullAdapter`, which never interrupts.
      Use `JobIteration::InterruptionAdapters.register(#{name.to_sym.inspect}, <adapter>) to register one.
      This will raise starting in version #{Deprecation.deprecation_horizon} of #{Deprecation.gem_name}!"
    DEPRECATION_MESSAGE

    NullAdapter
  end
end

.register(name, adapter) ⇒ Object

Registers adapter for specified name.

JobIteration::InterruptionAdapters.register(:sidekiq, MyCustomSidekiqAdapter)

Raises:

  • (ArgumentError)


29
30
31
32
33
# File 'lib/job-iteration/interruption_adapters.rb', line 29

def register(name, adapter)
  raise ArgumentError, "adapter must be callable" unless adapter.respond_to?(:call)

  registry[name.to_sym] = adapter
end