Method: WarpCore.dispatch_sync
- Defined in:
- lib/warpcore/sidekiq.rb
.dispatch_sync(worker_name, *args) ⇒ Object
Synchronously dispatch a Sidekiq worker with the provided arguments. This is equivalent to instantiating the worker instance directly and calling perform on it.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/warpcore/sidekiq.rb', line 61 def self.dispatch_sync(worker_name, *args) klass = worker_name.constantize object = klass.new if object.respond_to?(:perform) puts "=> [Dispatch:Sync] #{worker_name}" return object.perform(*args) else warn "Perform #{worker_name} not a valid Sidekiq worker." nil end rescue NameError => e puts "Worker [#{worker_name}] not defined." nil end |