Class: Mongo::Protocol::Msg Private
- Includes:
- Monitoring::Event::Secure
- Defined in:
- lib/mongo/protocol/msg.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
MongoDB Wire protocol Msg message (OP_MSG), a bi-directional wire protocol opcode.
OP_MSG is only available in MongoDB 3.6 (maxWireVersion >= 6) and later.
Constant Summary collapse
- DATABASE_IDENTIFIER =
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 identifier for the database name to execute the command on.
'$db'.freeze
Constants included from Monitoring::Event::Secure
Monitoring::Event::Secure::REDACTED_COMMANDS
Constants inherited from Message
Mongo::Protocol::Message::BATCH_SIZE, Mongo::Protocol::Message::COLLECTION, Mongo::Protocol::Message::LIMIT, Mongo::Protocol::Message::MAX_MESSAGE_SIZE, Mongo::Protocol::Message::ORDERED, Mongo::Protocol::Message::Q
Instance Attribute Summary
Attributes inherited from Message
Instance Method Summary collapse
-
#compress!(compressor, zlib_compression_level = nil) ⇒ Compressed, self
private
Compress this message.
-
#initialize(flags, options, global_args, *sections) ⇒ Msg
constructor
private
Creates a new OP_MSG protocol message.
-
#payload ⇒ BSON::Document
private
Return the event payload for monitoring.
-
#replyable? ⇒ true, false
private
Whether the message expects a reply from the database.
-
#serialize(buffer = BSON::ByteBuffer.new, max_bson_size = nil) ⇒ BSON::ByteBuffer
private
Serializes message into bytes that can be sent on the wire.
Methods included from Monitoring::Event::Secure
#compression_allowed?, #redacted
Methods inherited from Message
#==, deserialize, #hash, #inflate!, #number_returned, #set_request_id
Constructor Details
#initialize(flags, options, global_args, *sections) ⇒ Msg
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.
Creates a new OP_MSG protocol message
are :more_to_come and :checksum_present.
55 56 57 58 59 60 61 62 |
# File 'lib/mongo/protocol/msg.rb', line 55 def initialize(flags, , global_args, *sections) @flags = flags || [ :none ] = @global_args = global_args @sections = [ { type: 0, payload: global_args } ] + sections @request_id = nil super end |
Instance Method Details
#compress!(compressor, zlib_compression_level = nil) ⇒ Compressed, self
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.
Compress this message.
117 118 119 120 121 122 123 |
# File 'lib/mongo/protocol/msg.rb', line 117 def compress!(compressor, zlib_compression_level = nil) if compressor && compression_allowed?(command.keys.first) Compressed.new(self, compressor, zlib_compression_level) else self end end |
#payload ⇒ 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.
Return the event payload for monitoring.
84 85 86 87 88 89 90 91 92 |
# File 'lib/mongo/protocol/msg.rb', line 84 def payload BSON::Document.new( command_name: command.keys.first, database_name: global_args[DATABASE_IDENTIFIER], command: command, request_id: request_id, reply: sections[0] ) end |
#replyable? ⇒ true, false
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.
Whether the message expects a reply from the database.
72 73 74 |
# File 'lib/mongo/protocol/msg.rb', line 72 def replyable? @replyable ||= !flags.include?(:more_to_come) end |
#serialize(buffer = BSON::ByteBuffer.new, max_bson_size = 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 message into bytes that can be sent on the wire.
102 103 104 105 106 |
# File 'lib/mongo/protocol/msg.rb', line 102 def serialize(buffer = BSON::ByteBuffer.new, max_bson_size = nil) super add_check_sum(buffer) buffer end |