Class: AfElastic::EventReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/af_elastic.rb

Class Method Summary collapse

Class Method Details

.report_eventsObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/af_elastic.rb', line 90

def report_events
  events_to_report = AfElastic::EventStore.events || []
  return if events_to_report.length < AfElastic.configuration.capacity
  AfElastic::EventStore.events = []
  puts "about to bulk"

  th = Thread.new do 
    begin
        AfElastic.configuration.es.bulk body: events_to_report
     puts "bulk suceeded"
    rescue Exception => e
      puts "error bulk"
      Rails.logger.error("AfElastic::EventReporter::report_events: error doing bulk inserting")
    end         
  end
    return th
end