Module: Datadog::Core::Encoding::MsgpackEncoder

Extended by:
Encoder
Defined in:
lib/datadog/core/encoding.rb

Overview

Encoder for the Msgpack format

Constant Summary collapse

CONTENT_TYPE =
'application/msgpack'.freeze

Class Method Summary collapse

Class Method Details

.content_typeObject



55
56
57
# File 'lib/datadog/core/encoding.rb', line 55

def content_type
  CONTENT_TYPE
end

.encode(obj) ⇒ Object



59
60
61
# File 'lib/datadog/core/encoding.rb', line 59

def encode(obj)
  MessagePack.pack(obj)
end

.join(encoded_data) ⇒ Object



63
64
65
66
67
68
# File 'lib/datadog/core/encoding.rb', line 63

def join(encoded_data)
  packer = MessagePack::Packer.new
  packer.write_array_header(encoded_data.size)

  (packer.buffer.to_a + encoded_data).join
end