Class: SidekiqPublisher::Runner

Inherits:
Object
  • Object
show all
Extended by:
PrivateAttr
Defined in:
lib/sidekiq_publisher/runner.rb

Constant Summary collapse

LISTENER_TIMEOUT_SECONDS =
60
CHANNEL_NAME =
"sidekiq_publisher_job"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



18
19
20
# File 'lib/sidekiq_publisher/runner.rb', line 18

def initialize
  @publisher = Publisher.new
end

Class Method Details

.runObject



14
15
16
# File 'lib/sidekiq_publisher/runner.rb', line 14

def self.run
  new.run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/sidekiq_publisher/runner.rb', line 22

def run
  ActiveRecord::PostgresPubSub::Listener.listen(
    CHANNEL_NAME,
    listen_timeout: LISTENER_TIMEOUT_SECONDS
  ) do |listener|
    listener.on_start { publisher.publish }
    listener.on_notify { publisher.publish }
    listener.on_timeout { listener_timeout }
  end
end