Class: Mongo::Database::CursorCommandView Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/database/cursor_command_view.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The minimal view a Cursor needs when it is built from an arbitrary command response rather than from a collection query.

It carries the getMore-specific options (batchSize, maxTimeMS, comment) and the cursor type and timeout mode, and answers the few methods the Cursor reads from its view.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, options = {}) ⇒ CursorCommandView

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CursorCommandView.

Parameters:

  • database (Mongo::Database)

    The database the command ran on.

  • options (Hash) (defaults to: {})

    The getMore and timeout options.

Options Hash (options):

  • :batch_size (Integer)

    The batchSize for getMores.

  • :max_time_ms (Integer)

    The maxTimeMS for getMores.

  • :comment (Object)

    The comment for getMores.

  • :cursor_type (Symbol)

    :tailable or :tailable_await.

  • :timeout_mode (Symbol)

    :cursor_lifetime or :iteration.

Since:

  • 2.0.0



36
37
38
39
# File 'lib/mongo/database/cursor_command_view.rb', line 36

def initialize(database, options = {})
  @database = database
  @options = options
end

Instance Attribute Details

#databaseMongo::Database (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The database the command ran on.

Returns:

Since:

  • 2.0.0



42
43
44
# File 'lib/mongo/database/cursor_command_view.rb', line 42

def database
  @database
end

#optionsHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The view options. Used by the Cursor to read the getMore comment.

Returns:

  • (Hash)

    The view options. Used by the Cursor to read the getMore comment.

Since:

  • 2.0.0



46
47
48
# File 'lib/mongo/database/cursor_command_view.rb', line 46

def options
  @options
end

Instance Method Details

#batch_sizeInteger | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The batchSize sent on getMore commands.

Returns:

  • (Integer | nil)

    The batchSize sent on getMore commands.

Since:

  • 2.0.0



63
64
65
# File 'lib/mongo/database/cursor_command_view.rb', line 63

def batch_size
  options[:batch_size]
end

#clientMongo::Client

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The client.

Returns:

Since:

  • 2.0.0



49
50
51
# File 'lib/mongo/database/cursor_command_view.rb', line 49

def client
  database.client
end

#collectionMongo::Collection

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A placeholder collection used only so the Cursor can reach the client and database. The actual namespace for getMore and killCursors is taken from the command response, not from this collection.

Returns:

Since:

  • 2.0.0



58
59
60
# File 'lib/mongo/database/cursor_command_view.rb', line 58

def collection
  @collection ||= Collection.new(database, '$cmd')
end

#cursor_typeSymbol | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The cursor type.

Returns:

  • (Symbol | nil)

    The cursor type.

Since:

  • 2.0.0



73
74
75
# File 'lib/mongo/database/cursor_command_view.rb', line 73

def cursor_type
  options[:cursor_type]
end

#limitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Cursors do not support a limit when built from a command response.

Since:

  • 2.0.0



90
91
92
# File 'lib/mongo/database/cursor_command_view.rb', line 90

def limit
  nil
end

#max_time_ms_for_get_moreInteger | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The maxTimeMS sent on getMore commands.

Returns:

  • (Integer | nil)

    The maxTimeMS sent on getMore commands.

Since:

  • 2.0.0



68
69
70
# File 'lib/mongo/database/cursor_command_view.rb', line 68

def max_time_ms_for_get_more
  options[:max_time_ms]
end

#operation_timeouts(opts = {}) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns timeout values for the operation context.

Returns:

  • (Hash)

    timeout values for the operation context.

Since:

  • 2.0.0



83
84
85
# File 'lib/mongo/database/cursor_command_view.rb', line 83

def operation_timeouts(opts = {})
  database.operation_timeouts(opts)
end

#timeout_modeSymbol | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The timeout mode.

Returns:

  • (Symbol | nil)

    The timeout mode.

Since:

  • 2.0.0



78
79
80
# File 'lib/mongo/database/cursor_command_view.rb', line 78

def timeout_mode
  options[:timeout_mode]
end