Class: Fluent::StreamOutput::ReformatWriter

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

Instance Method Summary collapse

Constructor Details

#initialize(secondary) ⇒ ReformatWriter

Returns a new instance of ReformatWriter.



63
64
65
# File 'lib/fluent/plugin/out_stream.rb', line 63

def initialize(secondary)
  @secondary = secondary
end

Instance Method Details

#write(chunk) ⇒ Object



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

def write(chunk)
  chain = NullOutputChain.instance
  chunk.open {|io|
    # TODO use MessagePackIoEventStream
    u = Fluent::MessagePackFactory.msgpack_unpacker(io)
    begin
      u.each {|(tag,entries)|
        es = MultiEventStream.new
        entries.each {|o|
          es.add(o[0], o[1])
        }
        @secondary.emit(tag, es, chain)
      }
    rescue EOFError
    end
  }
end