Class: Fluent::RedoopOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_redoop.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

This method is called before starting.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fluent/plugin/out_redoop.rb', line 9

def configure(conf)
  super

  @redis = Redis.new(:host => "127.0.0.1", :port => 6379)

  params = {}
  params["key_1"] = conf["key_1"]
  params["key_2"] = conf["key_2"]

  puts "*********"
  puts params
  puts "*********"
end

#emit(tag, es, chain) ⇒ Object

This method is called when an event reaches Fluentd. ‘es’ is a Fluent::EventStream object that includes multiple events. You can use ‘es.each {|time,record| … }’ to retrieve events. ‘chain’ is an object that manages transactions. Call ‘chain.next’ at appropriate points and rollback if it raises an exception.



38
39
40
41
42
43
44
45
46
47
# File 'lib/fluent/plugin/out_redoop.rb', line 38

def emit(tag, es, chain)
  chain.next
  es.each {|time,record|
    score = Time.now.to_i
    @redis.zadd tag, score, record.to_json
    @redis.publish "mathematica", record.to_json
    # puts record
    $stderr.puts "OK!"
  }
end

#shutdownObject

This method is called when shutting down.



29
30
31
# File 'lib/fluent/plugin/out_redoop.rb', line 29

def shutdown
  super
end

#startObject

This method is called when starting.



24
25
26
# File 'lib/fluent/plugin/out_redoop.rb', line 24

def start
  super
end