Class: Fluent::RedisOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::RedisOutput
- Defined in:
- lib/fluent/plugin/out_redislist.rb
Instance Attribute Summary collapse
-
#db_number ⇒ Object
readonly
Returns the value of attribute db_number.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ RedisOutput
constructor
A new instance of RedisOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ RedisOutput
Returns a new instance of RedisOutput.
6 7 8 9 10 |
# File 'lib/fluent/plugin/out_redislist.rb', line 6 def initialize super require 'redis' require 'msgpack' end |
Instance Attribute Details
#db_number ⇒ Object (readonly)
Returns the value of attribute db_number.
4 5 6 |
# File 'lib/fluent/plugin/out_redislist.rb', line 4 def db_number @db_number end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/fluent/plugin/out_redislist.rb', line 4 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/fluent/plugin/out_redislist.rb', line 4 def port @port end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
4 5 6 |
# File 'lib/fluent/plugin/out_redislist.rb', line 4 def redis @redis end |
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/fluent/plugin/out_redislist.rb', line 12 def configure(conf) super @host = conf.has_key?('host') ? conf['host'] : 'localhost' @port = conf.has_key?('port') ? conf['port'].to_i : 6379 @db_number = conf.has_key?('db_number') ? conf['db_number'].to_i : nil end |
#format(tag, time, record) ⇒ Object
32 33 34 |
# File 'lib/fluent/plugin/out_redislist.rb', line 32 def format(tag, time, record) [tag, record].to_msgpack end |
#shutdown ⇒ Object
28 29 30 |
# File 'lib/fluent/plugin/out_redislist.rb', line 28 def shutdown @redis.quit end |
#start ⇒ Object
21 22 23 24 25 26 |
# File 'lib/fluent/plugin/out_redislist.rb', line 21 def start super @redis = Redis.new(:host => @host, :port => @port, :thread_safe => true, :db => @db_number) end |
#write(chunk) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fluent/plugin/out_redislist.rb', line 36 def write(chunk) @redis.pipelined { chunk.open { |io| begin MessagePack::Unpacker.new(io).each.each_with_index { |record, index| @redis.rpush record[0], record[1].to_json } rescue EOFError # EOFError always occured when reached end of chunk. end } } end |