module Mongo::Error::SdamErrorDetection
@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.
@api semipublic
Constants
- NODE_RECOVERING_CODES
@api private
- NODE_SHUTTING_DOWN_CODES
@api private
- NOT_MASTER_CODES
@api private
Public Instance Methods
node_recovering?()
click to toggle source
Whether the error is a “node is recovering” error, or one of its variants.
@return [ true | false ] Whether the error is a node is recovering.
@since 2.8.0
# File lib/mongo/error/sdam_error_detection.rb, line 52 def node_recovering? # Require the error to be communicated at the top level of the response # for it to influence SDAM state. See DRIVERS-1376 / RUBY-2516. return false if document && document['ok'] == 1 if code NODE_RECOVERING_CODES.include?(code) elsif message message.include?('node is recovering') || message.include?('not master or secondary') else false end end
node_shutting_down?()
click to toggle source
Whether the error is a “node is shutting down” type error.
@return [ true | false ] Whether the error is a node is shutting down.
@since 2.9.0
# File lib/mongo/error/sdam_error_detection.rb, line 73 def node_shutting_down? if code && NODE_SHUTTING_DOWN_CODES.include?(code) true else false end end
not_master?()
click to toggle source
Whether the error is a “not master” error, or one of its variants.
@return [ true | false ] Whether the error is a not master.
@since 2.8.0
# File lib/mongo/error/sdam_error_detection.rb, line 29 def not_master? # Require the error to be communicated at the top level of the response # for it to influence SDAM state. See DRIVERS-1376 / RUBY-2516. return false if document && document['ok'] == 1 if node_recovering? false elsif code NOT_MASTER_CODES.include?(code) elsif message message.include?('not master') else false end end