Class: Fluent::EventStream

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Plugin::Compressable
Defined in:
lib/fluent/event.rb

Instance Method Summary collapse

Methods included from Plugin::Compressable

#compress, #decompress

Instance Method Details

#==(other) ⇒ Object

for tests



40
41
42
# File 'lib/fluent/event.rb', line 40

def ==(other)
  other.is_a?(EventStream) && self.to_msgpack_stream == other.to_msgpack_stream
end

#dupObject

dup does deep copy for event stream

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/fluent/event.rb', line 26

def dup
  raise NotImplementedError, "DO NOT USE THIS CLASS directly."
end

#each(unapcker: nil, &block) ⇒ Object

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/fluent/event.rb', line 52

def each(unapcker: nil, &block)
  raise NotImplementedError, "DO NOT USE THIS CLASS directly."
end

#empty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fluent/event.rb', line 35

def empty?
  size == 0
end

#repeatable?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/fluent/event.rb', line 44

def repeatable?
  false
end

#sizeObject Also known as: length

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/fluent/event.rb', line 30

def size
  raise NotImplementedError, "DO NOT USE THIS CLASS directly."
end

#slice(index, num) ⇒ Object

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/fluent/event.rb', line 48

def slice(index, num)
  raise NotImplementedError, "DO NOT USE THIS CLASS directly."
end

#to_compressed_msgpack_stream(time_int: false, packer: nil) ⇒ Object



65
66
67
68
# File 'lib/fluent/event.rb', line 65

def to_compressed_msgpack_stream(time_int: false, packer: nil)
  packed = to_msgpack_stream(time_int: time_int, packer: packer)
  compress(packed)
end

#to_msgpack_stream(time_int: false, packer: nil) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/fluent/event.rb', line 56

def to_msgpack_stream(time_int: false, packer: nil)
  return to_msgpack_stream_forced_integer(packer: packer) if time_int
  out = packer || Fluent::MessagePackFactory.msgpack_packer
  each {|time,record|
    out.write([time,record])
  }
  out.full_pack
end

#to_msgpack_stream_forced_integer(packer: nil) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/fluent/event.rb', line 70

def to_msgpack_stream_forced_integer(packer: nil)
  out = packer || Fluent::MessagePackFactory.msgpack_packer
  each {|time,record|
    out.write([time.to_i,record])
  }
  out.full_pack
end