Class: FluQ::Feed::Tsv

Inherits:
Base
  • Object
show all
Defined in:
lib/fluq/feed/tsv.rb

Instance Attribute Summary

Attributes inherited from Base

#buffer

Class Method Summary collapse

Methods inherited from Base

#each, #initialize

Methods included from Mixins::Loggable

#logger

Constructor Details

This class inherits a constructor from FluQ::Feed::Base

Class Method Details

.to_event(raw) ⇒ Object

See Also:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fluq/feed/tsv.rb', line 4

def self.to_event(raw)
  tag, timestamp, json = raw.split("\t")

  case hash = Oj.load(json)
  when Hash
    FluQ::Event.new tag, timestamp, hash
  else
    logger.warn "buffer contained invalid event #{hash.inspect}"
    nil
  end
rescue Oj::ParseError, ArgumentError
  logger.warn "buffer contained invalid line #{raw.inspect}"
  nil
end