class Akakor::Indexer::Daemon

Public Class Methods

start() click to toggle source
# File lib/akakor/indexer/daemon.rb, line 8
def self.start
  new.start
end

Public Instance Methods

start() click to toggle source
# 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