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'

Class Method Summary collapse

Class Method Details

.content_typeObject



57
58
59
# File 'lib/datadog/core/encoding.rb', line 57

def content_type
  CONTENT_TYPE
end

.encode(obj) ⇒ Object



61
62
63
# File 'lib/datadog/core/encoding.rb', line 61

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

.join(encoded_data) ⇒ Object



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

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

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