Class: Mongo::Protocol::GetMore

Inherits:
Message
  • Object
show all
Defined in:
lib/mongo/protocol/get_more.rb

Overview

MongoDB Wire protocol GetMore message.

This is a client request message that is sent to the server in order to retrieve additional documents from a cursor that has already been instantiated.

The operation requires that you specify the database and collection name as well as the cursor id because cursors are scoped to a namespace.

Defined Under Namespace

Classes: Upconverter

Constant Summary

Constants inherited from Message

Message::BATCH_SIZE, Message::COLLECTION, Message::LIMIT, Message::MAX_MESSAGE_SIZE, Message::ORDERED, Message::Q

Instance Attribute Summary

Attributes inherited from Message

#request_id

Instance Method Summary collapse

Methods inherited from Message

#==, deserialize, #hash, #serialize, #set_request_id

Constructor Details

#initialize(database, collection, number_to_return, cursor_id) ⇒ GetMore

Creates a new GetMore message

Examples:

Get 15 additional documents from cursor 123 in 'xgen.users'.

GetMore.new('xgen', 'users', 15, 123)

Parameters:

  • database (String, Symbol)

    The database to query.

  • collection (String, Symbol)

    The collection to query.

  • number_to_return (Integer)

    The number of documents to return.

  • cursor_id (Integer)

    The cursor id returned in a reply.



39
40
41
42
43
44
45
46
# File 'lib/mongo/protocol/get_more.rb', line 39

def initialize(database, collection, number_to_return, cursor_id)
  @database = database
  @namespace = "#{database}.#{collection}"
  @number_to_return = number_to_return
  @cursor_id = cursor_id
  @upconverter = Upconverter.new(collection, cursor_id, number_to_return)
  super
end

Instance Method Details

#payloadHash

Return the event payload for monitoring.

Examples:

Return the event payload.

message.payload

Returns:

  • (Hash)

    The event payload.

Since:

  • 2.1.0



56
57
58
59
60
61
62
63
# File 'lib/mongo/protocol/get_more.rb', line 56

def payload
  {
    command_name: 'getMore',
    database_name: @database,
    command: upconverter.command,
    request_id: request_id
  }
end

#replyable?true

Get more messages require replies from the database.

Examples:

Does the message require a reply?

message.replyable?

Returns:

  • (true)

    Always true for get more.

Since:

  • 2.0.0



73
74
75
# File 'lib/mongo/protocol/get_more.rb', line 73

def replyable?
  true
end