Class: Fluent::RedisListOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::RedisListOutput
- Defined in:
- lib/fluent/plugin/out_redislist.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#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 ⇒ RedisListOutput
constructor
A new instance of RedisListOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ RedisListOutput
Returns a new instance of RedisListOutput.
6 7 8 9 10 11 12 |
# File 'lib/fluent/plugin/out_redislist.rb', line 6 def initialize super require 'redis' require 'msgpack' require 'socket' require 'json' end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
4 5 6 |
# File 'lib/fluent/plugin/out_redislist.rb', line 4 def database @database 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
14 15 16 17 18 19 20 |
# File 'lib/fluent/plugin/out_redislist.rb', line 14 def configure(conf) super @host = conf['host'] || 'localhost' @port = ( conf['port'] || '6379' ).to_i @database = ( conf['database'] || '0' ).to_i end |
#format(tag, time, record) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/fluent/plugin/out_redislist.rb', line 33 def format(tag, time, record) record["@node"] = @whereami record["@timestamp"] = Time.at(time).to_s # to avoid LOGSTASH-1340 record["@key"] = tag record.to_msgpack end |
#shutdown ⇒ Object
29 30 31 |
# File 'lib/fluent/plugin/out_redislist.rb', line 29 def shutdown @redis.quit end |
#start ⇒ Object
22 23 24 25 26 27 |
# File 'lib/fluent/plugin/out_redislist.rb', line 22 def start super @whereami = Socket.gethostname @redis = Redis.new(:host => @host, :port => @port, :db => @database) end |
#write(chunk) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fluent/plugin/out_redislist.rb', line 40 def write(chunk) @redis.pipelined { chunk.open { |io| begin MessagePack::Unpacker.new(io).each { |record| key = record.delete('@key') @redis.rpush key, record.to_json } rescue EOFError # EOFError always occured when reached end of chunk. end } } end |