Class: Moped::Protocol::GetMore
- Inherits:
-
Object
- Object
- Moped::Protocol::GetMore
- Includes:
- Message
- Defined in:
- lib/moped/protocol/get_more.rb
Overview
The Protocol class for retrieving more documents from a cursor.
Instance Attribute Summary collapse
-
#collection ⇒ String
The collection to query.
-
#cursor_id ⇒ Number
The id of the cursor to get more documents from.
- #database ⇒ Object
-
#full_collection_name ⇒ String
The namespaced collection name.
-
#length ⇒ Number
The length of the message.
-
#limit ⇒ Number
The number of documents to return.
-
#op_code ⇒ Integer
Get the code for a get more operation.
-
#request_id ⇒ Number
The request id of the message.
Instance Method Summary collapse
-
#failure?(reply) ⇒ true, false
Determine if the provided reply message is a failure with respect to a get more operation.
-
#failure_exception(reply) ⇒ Moped::Errors::CursorNotFound
Get the exception specific to a failure of this particular operation.
-
#initialize(database, collection, cursor_id, limit, options = {}) ⇒ GetMore
constructor
Create a new GetMore command.
-
#log_inspect ⇒ String
Provide the value that will be logged when the get more runs.
-
#receive_replies(connection) ⇒ Protocol::Reply
Receive replies to the message.
-
#results(reply) ⇒ Moped::Protocol::Reply
Take the provided reply and return the expected results to api consumers.
Methods included from Message
included, #inspect, #serialize
Constructor Details
#initialize(database, collection, cursor_id, limit, options = {}) ⇒ GetMore
Create a new GetMore command. The database and collection arguments are joined together to set the full_collection_name.
100 101 102 103 104 105 106 107 |
# File 'lib/moped/protocol/get_more.rb', line 100 def initialize(database, collection, cursor_id, limit, = {}) @database = database @collection = collection @full_collection_name = "#{database}.#{collection}" @cursor_id = cursor_id @limit = limit @request_id = [:request_id] end |
Instance Attribute Details
#collection ⇒ String
Returns The collection to query.
44 45 46 |
# File 'lib/moped/protocol/get_more.rb', line 44 def collection @collection end |
#cursor_id ⇒ Number
Returns the id of the cursor to get more documents from.
36 |
# File 'lib/moped/protocol/get_more.rb', line 36 int64 :cursor_id |
#database ⇒ Object
44 |
# File 'lib/moped/protocol/get_more.rb', line 44 attr_reader :collection, :database |
#full_collection_name ⇒ String
Returns the namespaced collection name.
28 |
# File 'lib/moped/protocol/get_more.rb', line 28 cstring :full_collection_name |
#length ⇒ Number
Returns the length of the message.
12 |
# File 'lib/moped/protocol/get_more.rb', line 12 int32 :length |
#limit ⇒ Number
Returns the number of documents to return.
32 |
# File 'lib/moped/protocol/get_more.rb', line 32 int32 :limit |
#op_code ⇒ Integer
Get the code for a get more operation.
22 |
# File 'lib/moped/protocol/get_more.rb', line 22 int32 :op_code |
#request_id ⇒ Number
Returns the request id of the message.
16 |
# File 'lib/moped/protocol/get_more.rb', line 16 int32 :request_id |
Instance Method Details
#failure?(reply) ⇒ true, false
Determine if the provided reply message is a failure with respect to a get more operation.
57 58 59 |
# File 'lib/moped/protocol/get_more.rb', line 57 def failure?(reply) reply.cursor_not_found? || reply.query_failure? end |
#failure_exception(reply) ⇒ Moped::Errors::CursorNotFound
Get the exception specific to a failure of this particular operation.
71 72 73 74 75 76 77 |
# File 'lib/moped/protocol/get_more.rb', line 71 def failure_exception(reply) if reply.cursor_not_found? Errors::CursorNotFound.new(self, cursor_id) else Errors::QueryFailure.new(self, reply.documents.first) end end |
#log_inspect ⇒ String
Provide the value that will be logged when the get more runs.
117 118 119 120 |
# File 'lib/moped/protocol/get_more.rb', line 117 def log_inspect type = "GET_MORE" "%-12s database=%s collection=%s limit=%s cursor_id=%s" % [type, database, collection, limit, cursor_id] end |
#receive_replies(connection) ⇒ Protocol::Reply
Receive replies to the message.
146 147 148 |
# File 'lib/moped/protocol/get_more.rb', line 146 def receive_replies(connection) connection.read end |
#results(reply) ⇒ Moped::Protocol::Reply
Take the provided reply and return the expected results to api consumers.
161 162 163 |
# File 'lib/moped/protocol/get_more.rb', line 161 def results(reply) reply end |