Class: Fluent::Plugin::FestivalInput

Inherits:
Input
  • Object
show all
Includes:
FestivalProxy
Defined in:
lib/fluent/plugin/in_festival.rb

Instance Method Summary collapse

Methods included from FestivalProxy

#add_location, #create_session, #create_session_request, #delete_session, #delete_session_request, #error_handler, #get_data, #get_data_header, #get_data_request, #get_historical_data, #resource_path, #resource_type, #shutdown_proxy, #start_proxy, #valid_session?

Instance Method Details

#configure(conf) ⇒ Object



65
66
67
# File 'lib/fluent/plugin/in_festival.rb', line 65

def configure(conf)
  super
end

#emit(record) ⇒ Object

Sample data from FESTIVAL IoT Gateway (sensinact) time_key must be set to “date” “1017.57”, “date”: “2017-03-29T16:19:15Z”



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fluent/plugin/in_festival.rb', line 87

def emit(record)
  begin
    time = Fluent::EventTime.now
    if record.is_a?(Array) # Multiple values case
      mes = Fluent::MultiEventStream.new
      record.each do |single_record|
        # use timestamp of the first sensor (single_record[0])
        mes.add(time, single_record)
      end
      router.emit_stream(@tag, mes)
    else # Single value case
      # use timestamp of the first sensor (single_record[0])
      router.emit(@tag, time, record)
    end
  rescue Exception => e
    log.error error: e.to_s
    log.debug_backtrace(e.backtrace)
  end
end

#shutdownObject



107
108
109
110
# File 'lib/fluent/plugin/in_festival.rb', line 107

def shutdown
  shutdown_proxy
  super
end

#startObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fluent/plugin/in_festival.rb', line 69

def start
  #raise StandardError.new if @tag.nil?
  super
  start_proxy
  timer_execute(:in_festival, @polling_interval) do
    begin
      data = get_data
      emit(data) if !(data.nil? || data.empty?)
    rescue Exception => e
      log.error error: e.to_s
      log.debug_backtrace(e.backtrace)
    end
  end
end