Class: EXEL::Sidekiq::SidekiqProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/exel/sidekiq/sidekiq_provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ SidekiqProvider

Returns a new instance of SidekiqProvider.

[View source]

7
8
9
# File 'lib/exel/sidekiq/sidekiq_provider.rb', line 7

def initialize(context)
  @context = context
end

Instance Method Details

#do_async(block) ⇒ Object

[View source]

11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/exel/sidekiq/sidekiq_provider.rb', line 11

def do_async(block)
  @context[:_block] = block

  worker_args = [@context.serialize, @context[:async_label]].compact

  # noinspection RubyStringKeysInHashInspection
  push_args = {'class' => EXEL::Sidekiq::ExecutionWorker, 'args' => worker_args}
  push_args['queue'] = @context[:queue] if @context[:queue]
  push_args['retry'] = @context[:retry] if @context[:retry]

  ::Sidekiq::Client.push(push_args)
end