Class: ActiveJob::QueueAdapters::KarafkaAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/karafka_adapter.rb

Overview

Karafka adapter for enqueuing jobs This is here for ease of integration with ActiveJob.

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object

Enqueues the job using the configured dispatcher

Parameters:

  • job (Object)

    job that should be enqueued



13
14
15
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 13

def enqueue(job)
  ::Karafka::App.config.internal.active_job.dispatcher.dispatch(job)
end

#enqueue_all(jobs) ⇒ Object

Enqueues multiple jobs in one go

Parameters:

  • jobs (Array<Object>)

    jobs that we want to enqueue



19
20
21
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 19

def enqueue_all(jobs)
  ::Karafka::App.config.internal.active_job.dispatcher.dispatch_many(jobs)
end

#enqueue_at(_job, _timestamp) ⇒ Object

Raises info, that Karafka backend does not support scheduling jobs

Parameters:

  • _job (Object)

    job we cannot enqueue

  • _timestamp (Time)

    time when job should run

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 27

def enqueue_at(_job, _timestamp)
  raise NotImplementedError, 'This queueing backend does not support scheduling jobs.'
end