Module: Mongo::Error::SdamErrorDetection

Included in:
OperationFailure, Parser
Defined in:
lib/mongo/error/sdam_error_detection.rb

Overview

Note:

Although not_master? and node_recovering? methods of this module are part of the public API, the fact that these methods are defined on this module and not on the classes which include this module is not part of the public API.

Since:

  • 2.0.0

Constant Summary collapse

NOT_MASTER_CODES =

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

Since:

  • 2.0.0

[10107, 13435].freeze
NODE_RECOVERING_CODES =

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

Since:

  • 2.0.0

[11600, 11602, 13436, 189, 91].freeze

Instance Method Summary collapse

Instance Method Details

#node_recovering?true | false

Returns:

  • (true | false)

    Whether the error is a node is recovering.

Since:

  • 2.8.0



43
44
45
46
47
48
49
50
51
# File 'lib/mongo/error/sdam_error_detection.rb', line 43

def node_recovering?
  if code && NODE_RECOVERING_CODES.include?(code)
    true
  elsif message
    message.include?('node is recovering') || message.include?('not master or secondary')
  else
    false
  end
end

#not_master?true | false

Returns:

  • (true | false)

    Whether the error is a not master.

Since:

  • 2.8.0



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mongo/error/sdam_error_detection.rb', line 24

def not_master?
  if node_recovering?
    false
  elsif code && NOT_MASTER_CODES.include?(code)
    true
  elsif message
    message.include?('not master')
  else
    false
  end
end