Method: Mongo::Connection#send_message

Defined in:
lib/mongo/connection.rb

#send_message(operation, message, log_message = nil) ⇒ True

Send a message to MongoDB, adding the necessary headers.

Parameters:

  • operation (Integer)

    a MongoDB opcode.

  • message (ByteBuffer)

    a message to send to the database.

  • log_message (String) (defaults to: nil)

    text version of message for logging.

Returns:

  • (True)


336
337
338
339
340
341
342
343
344
345
# File 'lib/mongo/connection.rb', line 336

def send_message(operation, message, log_message=nil)
  @logger.debug("  MONGODB #{log_message || message}") if @logger
  begin
    packed_message = add_message_headers(operation, message).to_s
    socket = checkout
    send_message_on_socket(packed_message, socket)
  ensure
    checkin(socket)
  end
end