Class: SearchKit::Events::Poll

Inherits:
Object
  • Object
show all
Defined in:
lib/search_kit/events/poll.rb,
lib/search_kit/events/poll/process.rb

Overview

This file houses the polling loop of the Event service.

Defined Under Namespace

Classes: Process

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, &block) ⇒ Poll

Returns a new instance of Poll.



14
15
16
17
# File 'lib/search_kit/events/poll.rb', line 14

def initialize(channel, &block)
  @block   = block
  @channel = channel
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



12
13
14
# File 'lib/search_kit/events/poll.rb', line 12

def block
  @block
end

#channelObject (readonly)

Returns the value of attribute channel.



12
13
14
# File 'lib/search_kit/events/poll.rb', line 12

def channel
  @channel
end

Class Method Details

.perform(channel, &block) ⇒ Object



8
9
10
# File 'lib/search_kit/events/poll.rb', line 8

def self.perform(channel, &block)
  new(channel, &block).perform
end

Instance Method Details

#performObject



19
20
21
22
23
24
# File 'lib/search_kit/events/poll.rb', line 19

def perform
  loop do
    process_queue
    sleep 1
  end
end

#process_queueObject



26
27
28
# File 'lib/search_kit/events/poll.rb', line 26

def process_queue
  SearchKit::Events::Poll::Process.perform(channel, &block)
end