Module Mongo::Networking
In: lib/mongo/networking.rb

Methods

Constants

STANDARD_HEADER_SIZE = 16
RESPONSE_HEADER_SIZE = 20
BINARY_ENCODING = Encoding.find("binary")

Public Instance methods

Sends a message to the database and waits for the response.

@param [Integer] operation a MongoDB opcode. @param [BSON::ByteBuffer] message a message to send to the database. @param [String] log_message this is currently a no-op and will be removed. @param [Socket] socket a socket to use in lieu of checking out a new one. @param [Boolean] command (false) indicate whether this is a command. If this is a command,

  the message will be sent to the primary node.

@param [Boolean] command (false) indicate whether the cursor should be exhausted. Set

  this to true only when the OP_QUERY_EXHAUST flag is set.

@return [Array]

  An array whose indexes include [0] documents returned, [1] number of document received,
  and [3] a cursor_id.

Send a message to MongoDB, adding the necessary headers.

@param [Integer] operation a MongoDB opcode. @param [BSON::ByteBuffer] message a message to send to the database.

@option opts [Symbol] :connection (:writer) The connection to which

  this message should be sent. Valid options are :writer and :reader.

@return [Integer] number of bytes sent

Sends a message to the database, waits for a response, and raises an exception if the operation has failed.

@param [Integer] operation a MongoDB opcode. @param [BSON::ByteBuffer] message a message to send to the database. @param [String] db_name the name of the database. used on call to get_last_error. @param [Hash] last_error_params parameters to be sent to getLastError. See DB#error for

  available options.

@see DB#get_last_error for valid last error params.

@return [Hash] The document returned by the call to getlasterror.

[Validate]