123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Protocol::GetMore

Relationships & Source Files
Namespace Children
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Message
Instance Chain:
Inherits: Mongo::Protocol::Message
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.

Constant Summary

Serializers - Included

HEADER_PACK, INT32_PACK, INT64_PACK, NULL, ZERO

Message - Inherited

BATCH_SIZE, COLLECTION, LIMIT, MAX_MESSAGE_SIZE, ORDERED, Q

Class Method Summary

Message - Inherited

.deserialize

Deserializes messages from an IO stream.

.new

:nodoc:

.deserialize_array

Deserializes an array of fields in a message.

.deserialize_field

Deserializes a single field in a message.

.deserialize_header

Deserializes the header of the message.

.field

A method for declaring a message field.

.fields

A class method for getting the fields for a message class.

Instance Attribute Summary

Message - Inherited

#replyable?

The default for messages is not to require a reply after sending a message to the server.

#request_id

Returns the request id for the message.

Instance Method Summary

Message - Inherited

#==

Tests for equality between two wire protocol messages by comparing class and field values.

#eql?

Alias for Message#==.

#hash

Creates a hash from the values of the fields of a message.

#maybe_add_server_api,
#maybe_compress

Compress the message, if supported by the wire protocol used and if the command being sent permits compression.

#maybe_decrypt

Possibly decrypt this message with libmongocrypt.

#maybe_encrypt

Possibly encrypt this message with libmongocrypt.

#maybe_inflate

Inflate a message if it is compressed.

#number_returned

Default number returned value for protocol messages.

#serialize

Serializes message into bytes that can be sent on the wire.

#set_request_id

Generates a request id for a message.

#to_s
#compress_if_possible

Compress the message, if the command being sent permits compression.

#fields

A method for getting the fields for a message class.

#merge_sections,
#serialize_fields

Serializes message fields into a buffer.

#serialize_header

Serializes the header of the message consisting of 4 32bit integers.

Constructor Details

.new(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.

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 42

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 Attribute Details

#cursor_idFixnum (rw, private)

Returns:

  • (Fixnum)

    The cursor id to get more documents from.

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 105

field :cursor_id, Int64

#namespaceString (rw, private)

Returns:

  • (String)

    The namespace for this getMore message.

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 97

field :namespace, CString

#number_to_returnFixnum (rw, private)

Returns:

  • (Fixnum)

    The number to return for this getMore message.

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 101

field :number_to_return, Int32

#replyable?true (readonly)

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

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 76

def replyable?
  true
end

Instance Method Details

#payloadBSON::Document

Return the event payload for monitoring.

Examples:

Return the event payload.

message.payload

Returns:

  • (BSON::Document)

    The event payload.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/protocol/get_more.rb', line 59

def payload
  BSON::Document.new(
    command_name: 'getMore',
    database_name: @database,
    command: upconverter.command,
    request_id: request_id
  )
end