class Mongo::Operation::Insert::OpMsg

A MongoDB insert operation sent as an op message.

@api private

@since 2.5.2

Public Instance Methods

execute(server) click to toggle source

Execute the operation.

@example

operation.execute(server)

@param [ Mongo::Server ] server The server to send the operation to.

@return [ Mongo::Operation::Insert::Result ] The operation result.

@since 2.5.2

# File lib/mongo/operation/insert/op_msg.rb, line 41
def execute(server)
  result = Result.new(dispatch_message(server), @ids)
  process_result(result, server)
rescue Mongo::Error::SocketError => e
  e.send(:add_label, Mongo::Error::TRANSIENT_TRANSACTION_ERROR_LABEL) if session.in_transaction?
  raise e
end

Private Instance Methods

message(server) click to toggle source
# File lib/mongo/operation/insert/op_msg.rb, line 57
def message(server)
  section = { type: 1, payload: { identifier: IDENTIFIER, sequence: send(IDENTIFIER) } }
  Protocol::Msg.new(flags, { validating_keys: true }, command(server), section)
end
selector(server) click to toggle source
# File lib/mongo/operation/insert/op_msg.rb, line 51
def selector(server)
  { insert: coll_name,
    Protocol::Msg::DATABASE_IDENTIFIER => db_name,
    ordered: ordered? }
end