class Fluent::MemoryBufferChunk
Attributes
unique_id[R]
Public Class Methods
new(key, data='')
click to toggle source
Calls superclass method
Fluent::BufferChunk.new
# File lib/fluent/plugin/buf_memory.rb, line 20 def initialize(key, data='') @data = data @data.force_encoding('ASCII-8BIT') now = Time.now.utc u1 = ((now.to_i*1000*1000+now.usec) << 12 | rand(0xfff)) @unique_id = [u1 >> 32, u1 & 0xffffffff, rand(0xffffffff), rand(0xffffffff)].pack('NNNN') super(key) end
Public Instance Methods
<<(data)
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 31 def <<(data) data.force_encoding('ASCII-8BIT') @data << data end
close()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 40 def close end
msgpack_each(&block)
click to toggle source
optimize
# File lib/fluent/plugin/buf_memory.rb, line 60 def msgpack_each(&block) u = MessagePack::Unpacker.new u.feed_each(@data, &block) end
open(&block)
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 50 def open(&block) StringIO.open(@data, &block) end
purge()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 43 def purge end
read()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 46 def read @data end
size()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 36 def size @data.bytesize end
write_to(io)
click to toggle source
optimize
# File lib/fluent/plugin/buf_memory.rb, line 55 def write_to(io) io.write @data end