Class Mongo::Protocol::Msg
In: lib/mongo/protocol/msg.rb
Parent: Message

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.

@api private

@since 2.5.0

Methods

compress!   new   payload   replyable?   serialize  

Included Modules

Monitoring::Event::Secure

Constants

DATABASE_IDENTIFIER = '$db'.freeze   The identifier for the database name to execute the command on.

@since 2.5.0

OP_CODE = 2013   The operation code required to specify a OP_MSG message. @return [ Fixnum ] the operation code.

@since 2.5.0

FLAGS = Array.new(16).tap { |arr| arr[0] = :checksum_present   Available flags for a OP_MSG message.

External Aliases

sections -> documents

Public Class methods

Creates a new OP_MSG protocol message

@example Create a OP_MSG wire protocol message

  Msg.new([:more_to_come], {}, { ismaster: 1 },
          { type: 1, payload: { identifier: 'documents', sequence: [..] } })

@param [ Array<Symbol> ] flags The flag bits. Current supported values are :more_to_come and :checksum_present. @param [ Hash ] options The options. There are currently no supported

  options, this is a placeholder for the future.

@param [ BSON::Document, Hash ] global_args The global arguments,

  becomes a section of payload type 0.

@param [ BSON::Document, Hash ] sections Zero or more sections, in the format

  { type: 1, payload: { identifier: <String>, sequence: <Array<BSON::Document, Hash>> } } or
  { type: 0, payload: <BSON::Document, Hash> }

@option options [ true, false ] validating_keys Whether keys should be validated.

@api private

@since 2.5.0

Public Instance methods

Compress this message.

@param [ String, Symbol ] compressor The compressor to use. @param [ Integer ] zlib_compression_level The zlib compression level to use.

@return [ Compressed, self ] A Protocol::Compressed message or self, depending on whether

 this message can be compressed.

@since 2.5.0

Return the event payload for monitoring.

@example Return the event payload.

  message.payload

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

@since 2.5.0

Whether the message expects a reply from the database.

@example Does the message require a reply?

  message.replyable?

@return [ true, false ] If the message expects a reply.

@since 2.5.0

Serializes message into bytes that can be sent on the wire.

@param [ BSON::ByteBuffer ] buffer where the message should be inserted. @param [ Integer ] max_bson_size The maximum bson object size.

@return [ BSON::ByteBuffer ] buffer containing the serialized message.

@since 2.5.0

[Validate]