Class: SearchKit::Polling

Inherits:
Object
  • Object
show all
Defined in:
lib/search_kit/polling.rb,
lib/search_kit/polling/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) ⇒ Polling

Returns a new instance of Polling.



13
14
15
16
# File 'lib/search_kit/polling.rb', line 13

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



11
12
13
# File 'lib/search_kit/polling.rb', line 11

def block
  @block
end

#channelObject (readonly)

Returns the value of attribute channel.



11
12
13
# File 'lib/search_kit/polling.rb', line 11

def channel
  @channel
end

Class Method Details

.perform(channel, &block) ⇒ Object



7
8
9
# File 'lib/search_kit/polling.rb', line 7

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

Instance Method Details

#performObject



18
19
20
21
22
23
# File 'lib/search_kit/polling.rb', line 18

def perform
  loop do
    process_queue
    sleep 1
  end
end

#process_queueObject



25
26
27
# File 'lib/search_kit/polling.rb', line 25

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