Class | Moped::Protocol::Reply |
In: |
lib/moped/protocol/reply.rb
|
Parent: | Object |
The Protocol class representing messages received from a mongo connection.
@example
socket = TCPSocket.new "127.0.0.1", 27017 command = Moped::Protocol::Command.new "admin", buildinfo: 1 socket.write command.serialize reply = Moped::Protocol::Reply.deserialize(socket) reply.documents[0]["version"] # => "2.0.0"
UNAUTHORIZED | = | [ 10057, 16550 ] | Unauthorized assertion errors. |
Consumes a buffer, returning the deserialized Reply message.
@example
socket = TCPSocket.new "localhost", 27017 socket.write Moped::Protocol::Command.new(:admin, ismaster: 1).serialize reply = Moped::Protocol::Reply.deserialize(socket) reply.documents[0]['ismaster'] # => 1
@param [read] buffer an IO or IO-like resource to deserialize the reply from. @return [Reply] the deserialized reply
Is the reply the result of a command failure?
@example Did the command fail?
reply.command_failure?
@note This is when ok is not 1, or "err" or "errmsg" are present.
@return [ true, false ] If the command failed.
@since 1.2.10
Was the provided cursor id not found on the server?
@example Is the cursor not on the server?
reply.cursor_not_found?
@return [ true, false ] If the cursor went missing.
@since 1.2.0
Check if the first returned document in the reply is an error result.
@example Is the first document in the reply an error?
reply.error?
@return [ true, false ] If the first document is an error.
@since 2.0.0
Did the query fail on the server?
@example Did the query fail?
reply.query_failure?
@return [ true, false ] If the query failed.
@since 1.2.0
Is the reply an error message that we are not authorized for the query or command?
@example Was the query unauthorized.
reply.unauthorized?
@note So far this can be a "code" of 10057 in the error message or an
"assertionCode" of 10057.
@return [ true, false ] If we had an authorization error.
@since 1.2.10