Class: Fluent::RedisOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::RedisOutput
- Defined in:
- lib/fluent/plugin/out_redis.rb
Instance Attribute Summary collapse
-
#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.
16 17 18 19 20 |
# File 'lib/fluent/plugin/out_redis.rb', line 16 def initialize super require 'redis' require 'msgpack' end |
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
4 5 6 |
# File 'lib/fluent/plugin/out_redis.rb', line 4 def redis @redis end |
Instance Method Details
#configure(conf) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fluent/plugin/out_redis.rb', line 22 def configure(conf) super if conf.has_key?('namespace') log.warn "namespace option has been removed from fluent-plugin-redis 0.1.3. Please add or remove the namespace '#{conf['namespace']}' manually." end end |
#format(tag, time, record) ⇒ Object
49 50 51 52 |
# File 'lib/fluent/plugin/out_redis.rb', line 49 def format(tag, time, record) identifier = [tag, time].join(".") [identifier, record].to_msgpack end |
#shutdown ⇒ Object
44 45 46 47 |
# File 'lib/fluent/plugin/out_redis.rb', line 44 def shutdown @redis.quit super end |
#start ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/out_redis.rb', line 30 def start super = { :host => @host, :port => @port, :thread_safe => true, :db => @db_number } [:password] = @password if @password @redis = Redis.new() end |
#write(chunk) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fluent/plugin/out_redis.rb', line 54 def write(chunk) @redis.pipelined { chunk.open { |io| begin MessagePack::Unpacker.new(io).each.each_with_index { |record, index| @redis.mapped_hmset "#{record[0]}.#{index}", record[1] } rescue EOFError # EOFError always occured when reached end of chunk. end } } end |