Class: Akakor::Indexer::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/akakor/indexer/daemon.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



8
9
10
# File 'lib/akakor/indexer/daemon.rb', line 8

def self.start
  new.start
end

Instance Method Details

#startObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/akakor/indexer/daemon.rb', line 12

def start
  redis = Redis.new
  es = Elasticsearch::Client.new
  while true do
    workobject = JSON.parse(redis.blpop('workobject', 0)[1])
    if workobject['F_InstrSheetName'] == "Terminate"
      es.delete index: 'workobjects_current', type: 'wob', id: workobject['F_WobNum']
    else
      es.index index: 'workobjects_current', type: 'wob', id: workobject['F_WobNum'], body: workobject
    end
    es.index index: 'workobjects_history', type: 'wob', body: workobject
  end
end