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 19 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 30 def <<(data) data.force_encoding('ASCII-8BIT') @data << data end
close()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 39 def close end
msgpack_each(&block)
click to toggle source
optimize
# File lib/fluent/plugin/buf_memory.rb, line 59 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 49 def open(&block) StringIO.open(@data, &block) end
purge()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 42 def purge end
read()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 45 def read @data end
size()
click to toggle source
# File lib/fluent/plugin/buf_memory.rb, line 35 def size @data.bytesize end
write_to(io)
click to toggle source
optimize
# File lib/fluent/plugin/buf_memory.rb, line 54 def write_to(io) io.write @data end