Module: Mongo::Protocol::Serializers::Sections::PayloadOne Private
- Defined in:
- lib/mongo/protocol/serializers.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
MongoDB wire protocol serialization strategy for a payload 1 type Section of OP_MSG.
Constant Summary collapse
- TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The byte identifier for this payload type.
0x1- TYPE_BYTE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The byte corresponding to this payload type.
TYPE.chr.force_encoding(BSON::BINARY).freeze
Class Method Summary collapse
-
.deserialize(buffer, _options = {}) ⇒ Array<BSON::Document>
private
Deserializes a section of payload type 1 of an OP_MSG from the IO stream.
-
.serialize(buffer, value, max_bson_size = nil, _validating_keys = nil) ⇒ BSON::ByteBuffer
private
Serializes a section of an OP_MSG, payload type 1.
Class Method Details
.deserialize(buffer, _options = {}) ⇒ Array<BSON::Document>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Deserializes a section of payload type 1 of an OP_MSG from the IO stream.
322 323 324 |
# File 'lib/mongo/protocol/serializers.rb', line 322 def self.deserialize(buffer, = {}) raise NotImplementedError end |
.serialize(buffer, value, max_bson_size = nil, _validating_keys = nil) ⇒ BSON::ByteBuffer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serializes a section of an OP_MSG, payload type 1.
304 305 306 307 308 309 310 311 312 313 |
# File 'lib/mongo/protocol/serializers.rb', line 304 def self.serialize(buffer, value, max_bson_size = nil, _validating_keys = nil) buffer.put_byte(TYPE_BYTE) start = buffer.length buffer.put_int32(0) # hold for size buffer.put_cstring(value[:identifier]) value[:sequence].each do |document| Document.serialize(buffer, document, max_bson_size) end buffer.replace_int32(start, buffer.length - start) end |