123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Protocol::KillCursors

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/kill_cursors.rb

Overview

MongoDB Wire protocol KillCursors message.

This is a client request message that is sent to the server in order to kill a number of cursors.

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(collection, database, cursor_ids) ⇒ KillCursors

Creates a new KillCursors message

Examples:

Kill the cursor on the server with id 1.

KillCursors.new([1])

Parameters:

  • collection (Mongo::Database)

    The collection.

  • database (Mongo::Database)

    The database.

  • cursor_ids (Array<Fixnum>)

    The cursor ids to kill.

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 37

def initialize(collection, database, cursor_ids)
  @database = database
  @cursor_ids = cursor_ids
  @id_count   = @cursor_ids.size
  @upconverter = Upconverter.new(collection, cursor_ids)
  super
end

Instance Attribute Details

#cursor_idsArray<Fixnum> (rw, private)

Returns:

  • (Array<Fixnum>)

    Cursors to kill.

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 83

field :cursor_ids, Int64, true

#id_countFixnum (rw, private)

Returns:

  • (Fixnum)

    Count of the number of cursor ids.

[ GitHub ]

  
# File 'lib/mongo/protocol/kill_cursors.rb', line 79

field :id_count, Int32

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/kill_cursors.rb', line 53

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