Class: ActiveJob::QueueAdapters::ShoryukenConcurrentSendAdapter
- Inherits:
-
ShoryukenAdapter
- Object
- ShoryukenAdapter
- ActiveJob::QueueAdapters::ShoryukenConcurrentSendAdapter
- Defined in:
- lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb
Overview
Shoryuken concurrent adapter for Active Job.
This adapter sends messages asynchronously (ie non-blocking) and allows the caller to set up handlers for both success and failure.
Instance Method Summary collapse
-
#enqueue(job, options = {}) ⇒ Concurrent::Promises::Future
Enqueues a job asynchronously.
-
#error_handler ⇒ Proc
Returns the error handler, using a default logger if not set.
-
#initialize(success_handler = nil, error_handler = nil) ⇒ ShoryukenConcurrentSendAdapter
constructor
Initializes a new concurrent send adapter.
-
#success_handler ⇒ Proc
Returns the success handler, using a default no-op if not set.
Methods inherited from ShoryukenAdapter
enqueue, #enqueue_after_transaction_commit?, #enqueue_all, enqueue_at, #enqueue_at, instance, #stopping?
Constructor Details
#initialize(success_handler = nil, error_handler = nil) ⇒ ShoryukenConcurrentSendAdapter
Initializes a new concurrent send adapter
26 27 28 29 30 |
# File 'lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb', line 26 def initialize(success_handler = nil, error_handler = nil) super() if defined?(super) @success_handler = success_handler @error_handler = error_handler end |
Instance Method Details
#enqueue(job, options = {}) ⇒ Concurrent::Promises::Future
Enqueues a job asynchronously
40 41 42 |
# File 'lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb', line 40 def enqueue(job, = {}) send_concurrently(job, ) { |f_job, | super(f_job, ) } end |
#error_handler ⇒ Proc
Returns the error handler, using a default logger if not set
54 55 56 57 58 |
# File 'lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb', line 54 def error_handler @error_handler ||= lambda { |error, job, | Shoryuken.logger.warn("Failed to enqueue job: #{job.inspect} due to error: #{error}") } end |
#success_handler ⇒ Proc
Returns the success handler, using a default no-op if not set
47 48 49 |
# File 'lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb', line 47 def success_handler @success_handler ||= ->(, _job, ) { nil } end |