module BSON::LogStashEvent

Injects behaviour for encoding and decoding time values to and from raw bytes as specified by the BSON spec.

@see bsonspec.org/#/specification

Constants

BSON_TYPE

An Event is an embedded document is type 0x03 in the BSON spec..

Public Instance Methods

to_bson(buffer = ByteBuffer.new) click to toggle source

Get the event as encoded BSON. @example Get the hash as encoded BSON.

Event.new("field" => "value").to_bson

@return [ String ] The encoded string. @see bsonspec.org/#/specification

# File lib/logstash/outputs/bson/logstash_event.rb, line 33
 def to_bson(buffer = ByteBuffer.new)
  position = buffer.length
  buffer.put_int32(0)
  to_hash.each do |field, value|
    buffer.put_byte(value.bson_type)
    buffer.put_cstring(field.to_bson_key)
    value.to_bson(buffer)
  end
  buffer.put_byte(NULL_BYTE)
  buffer.replace_int32(position, buffer.length - position)
end
to_bson_normalized_value() click to toggle source

Converts the event to a normalized value in a BSON document. @example Convert the event to a normalized value.

event.to_bson_normalized_value

@return [ BSON::Document ] The normalized event.

# File lib/logstash/outputs/bson/logstash_event.rb, line 49
def to_bson_normalized_value
  Document.new(self)
end