CursorHost — Documentation by YARD 0.9.37 (original) (raw)

Module: Mongo::CursorHost

Overview

A shared concern implementing settings and configuration for entities that “host” (or spawn) cursors.

The class or module that includes this concern must implement:

* timeout_ms -- this must return either the operation level timeout_ms
    (if set) or an inherited timeout_ms from a hierarchically higher
    level (if any).

Instance Attribute Summary collapse

Instance Method Summarycollapse

Instance Attribute Details

#cursor ⇒ nil | Cursor

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 associated with this view, if any.

17 18 19 # File 'lib/mongo/cursor_host.rb', line 17 def cursor @cursor end

#timeout_mode ⇒ :cursor_lifetime | :iteration

Returns The timeout mode to be used by this object.

21 22 23 # File 'lib/mongo/cursor_host.rb', line 21 def timeout_mode @timeout_mode end

Instance Method Details

#validate_timeout_mode!(options, forbid: []) ⇒ Object

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.

Ensure the timeout mode is appropriate for other options that have been given.

rubocop:disable Metrics

| 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # File 'lib/mongo/cursor_host.rb', line 35 def validate_timeout_mode!(options, forbid: []) forbid.each do |key| raise ArgumentError, "#{key} is not allowed here" if options.key?(key) end cursor_type = options[:cursor_type] timeout_mode = options[:timeout_mode] if timeout_ms if cursor_type timeout_mode | |= :iteration if timeout_mode == :cursor_lifetime raise ArgumentError, 'tailable cursors only support `timeout_mode: :iteration`' end max_await_time_ms = options[:max_await_time_ms] | | 0 if cursor_type == :tailable_await && max_await_time_ms >= timeout_ms raise ArgumentError, ':max_await_time_ms must not be >= :timeout_ms' end else timeout_mode | |= :cursor_lifetime end elsif timeout_mode raise ArgumentError, ':timeout_ms must be set if :timeout_mode is set' end if timeout_mode == :iteration && respond_to?(:write?) && write? raise ArgumentError, 'timeout_mode=:iteration is not supported for aggregation pipelines with outorout or outormerge' end @timeout_mode = timeout_mode end | | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |