Class: SidekiqPublisher::Runner

Inherits:
Object
  • Object
show all
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.



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

def initialize
  @publisher = Publisher.new
end

Class Method Details

.runObject



10
11
12
# File 'lib/sidekiq_publisher/runner.rb', line 10

def self.run
  new.run
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/sidekiq_publisher/runner.rb', line 18

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