Class: ActiveJob::QueueAdapters::KarafkaAdapter
- Inherits:
-
Object
- Object
- ActiveJob::QueueAdapters::KarafkaAdapter
- 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
-
#enqueue(job) ⇒ Object
Enqueues the job using the configured dispatcher.
-
#enqueue_after_transaction_commit? ⇒ true
Should we by default enqueue after the transaction and not during.
-
#enqueue_all(jobs) ⇒ Integer
Enqueues multiple jobs in one go.
-
#enqueue_at(job, timestamp) ⇒ Object
Delegates time sensitive dispatch to the dispatcher.
-
#stopping? ⇒ Boolean
Should we stop the job.
Instance Method Details
#enqueue(job) ⇒ Object
Enqueues the job using the configured dispatcher
41 42 43 |
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 41 def enqueue(job) dispatcher.dispatch(job) end |
#enqueue_after_transaction_commit? ⇒ true
Returns should we by default enqueue after the transaction and not during. Defaults to true to prevent weird issues during rollbacks, etc.
64 65 66 |
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 64 def enqueue_after_transaction_commit? true end |
#enqueue_all(jobs) ⇒ Integer
Enqueues multiple jobs in one go
48 49 50 51 |
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 48 def enqueue_all(jobs) dispatcher.dispatch_many(jobs) jobs.size end |
#enqueue_at(job, timestamp) ⇒ Object
Delegates time sensitive dispatch to the dispatcher. OSS will raise error, Pro will handle this as it supports scheduled messages.
58 59 60 |
# File 'lib/active_job/queue_adapters/karafka_adapter.rb', line 58 def enqueue_at(job, ) dispatcher.dispatch_at(job, ) end |