Class: Fluent::BufferChunk

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/fluent/buffer.rb

Direct Known Subclasses

FileBufferChunk, MemoryBufferChunk

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ BufferChunk

Returns a new instance of BufferChunk.



78
79
80
81
# File 'lib/fluent/buffer.rb', line 78

def initialize(key)
  super()
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



83
84
85
# File 'lib/fluent/buffer.rb', line 83

def key
  @key
end

Instance Method Details

#<<(data) ⇒ Object

Raises:

  • (NotImplementedError)


85
86
87
# File 'lib/fluent/buffer.rb', line 85

def <<(data)
  raise NotImplementedError, "Implement this method in child class"
end

#closeObject

Raises:

  • (NotImplementedError)


97
98
99
# File 'lib/fluent/buffer.rb', line 97

def close
  raise NotImplementedError, "Implement this method in child class"
end

#empty?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/fluent/buffer.rb', line 93

def empty?
  size == 0
end

#msgpack_each(&block) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/fluent/buffer.rb', line 119

def msgpack_each(&block)
  open {|io|
    u = Fluent::Engine.msgpack_factory.unpacker(io)
    begin
      u.each(&block)
    rescue EOFError
    end
  }
end

#openObject

Raises:

  • (NotImplementedError)


109
110
111
# File 'lib/fluent/buffer.rb', line 109

def open
  raise NotImplementedError, "Implement this method in child class"
end

#purgeObject

Raises:

  • (NotImplementedError)


101
102
103
# File 'lib/fluent/buffer.rb', line 101

def purge
  raise NotImplementedError, "Implement this method in child class"
end

#readObject

Raises:

  • (NotImplementedError)


105
106
107
# File 'lib/fluent/buffer.rb', line 105

def read
  raise NotImplementedError, "Implement this method in child class"
end

#sizeObject

Raises:

  • (NotImplementedError)


89
90
91
# File 'lib/fluent/buffer.rb', line 89

def size
  raise NotImplementedError, "Implement this method in child class"
end

#write_to(io) ⇒ Object



113
114
115
116
117
# File 'lib/fluent/buffer.rb', line 113

def write_to(io)
  open {|i|
    FileUtils.copy_stream(i, io)
  }
end