Class: Wisper::SidekiqBroadcaster

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

Overview

Defined Under Namespace

Classes: Worker

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registerObject



27
28
29
30
31
32
# File 'lib/wisper/sidekiq.rb', line 27

def self.register
  Wisper.configure do |config|
    config.broadcaster :sidekiq, SidekiqBroadcaster.new
    config.broadcaster :async,   SidekiqBroadcaster.new
  end
end

Instance Method Details

#broadcast(subscriber, _publisher, event, *args, **kwargs) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/wisper/sidekiq.rb', line 34

def broadcast(subscriber, _publisher, event, *args, **kwargs)
  options = sidekiq_options(subscriber)
  schedule_options = sidekiq_schedule_options(subscriber, event)

  Worker.set(options).perform_in(
    schedule_options.fetch(:delay, 0),
    ::YAML.dump([subscriber, event, args, kwargs])
  )
end