模块:OperationFailure::Family
- 扩展方式:
- 可转发
- 定义于:
- lib/ Mongo/error/operation_failure.rb
Overview
实现针对 OperationFailure 错误的行为。 其他错误(例如 ServerTimeoutError) 也可能会实现这一点,因此它们可能会被识别并视为 OperationFailure 错误。
常量摘要折叠
- CHANGE_STREAM_RESUME_ERRORS =
此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。
错误代码和代码名称,应导致变更流上的 getMore 命令失败而无法恢复。
[ { code_name: 'HostUnreachable', 代码: 6 }, { code_name: ' HostNotFound ', 代码: 7 }, { code_name: ' NetworkTimeout ', 代码: 89 }, { code_name: ' ShutdownInProgress ', 代码: 91 }, { code_name: ' PrimarySteppedDown ', 代码: 189 }, { code_name: 'ExceededTimeLimit', 代码: 262 }, { code_name: ' SocketException ', 代码: 9001 }, { code_name: ' NotMaster ', 代码: 10 _ 107 }, { code_name: ' InterruptedAtShutdown ', 代码: 11 _ 600 }, { code_name: ' InterruptedDueToReplStateChange ', 代码: 11 _ 602 }, { code_name: ' NotPrimaryNoSecondaryOk ', 代码: 13 _ 435 }, { code_name: ' NotMasterOrSecondary ', 代码: 13 _ 436 }, { code_name: ' StaleShardVersion ', 代码: 63 }, { code_name: ' FailedToSatisfyReadPreference ', 代码: 133 }, { code_name: 'StaleEpoch', 代码: 150 }, { code_name: ' RetryChangeStream ', 代码: 234 }, { code_name: ' StaleConfig ', 代码: 13 _ 388 }, ].冻结
- CHANGE_STREAM_RESUME_MESSAGES =
此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。
遇到这些错误消息时,可以恢复变更流。
ReadWriteRetryable::WRITE_RETRY_MESSAGES
Mongo::Error::ReadWriteRetryable 中包含的常量
Mongo::Error::ReadWriteRetryable::RETRY_MESSAGES、Mongo::Error::ReadWriteRetryable::WRITE_RETRY_ERRORS、Mongo::Error::ReadWriteRetryable::WRITE_RETRY_MESSAGES
Mongo::Error::SdamErrorDetection 中包含的常量
Mongo::Error::SdamErrorDetection::NODE_RECOVERING_CodeS 、 Mongo::Error::SdamErrorDetection::NODE_SHUTTING_down_codes 、 Mongo::Error::SdamErrorDetection::NOT_MASTER_CodeS
实例属性摘要折叠
-
# code ⇒ 整数
只读
从文档中解析的错误代码。
-
# code_name ⇒ string
只读
从文档中解析的错误代码名称。
-
#详细信息⇒ string | nil
只读
错误的详细信息。
-
#document ⇒ BSON::Document | nil
只读
服务器返回的错误文档。
-
# 结果 ="Operation::Result"
只读
private
操作的结果对象。
-
# server_message ⇒ string
只读
从响应中解析出服务器返回的错误消息。
-
# write_concern_error_code ⇒ 整数 | nil
只读
写关注错误的错误代码(如果存在写关注错误并具有代码)。
-
# write_concern_error_code_name ⇒ string | nil
只读
如果写关注(write concern)错误存在且具有代码名称,则为写关注(write concern)关注错误的代码名称。
-
# write_concern_error_document ⇒ 哈希 | nil
只读
返回服务器报告的写关注错误文档(如果有)。
实例方法摘要折叠
-
# change_stream_resumable? ⇒ true, false
如果触发此错误的操作是 getMore,则发生此错误的变更流能否恢复?
-
# connection_description ⇒ Server::Description
private
在该服务器上执行此异常所指操作的服务器描述。
-
#initialize (message = nil, result = nil, options = {}) ⇒ 对象
创建操作失败。
-
# max_time_ms_expired? ⇒ true | false
错误是否为 MaxTimeMSExpired。
-
# write_concern_error? ⇒ true | false
故障是否包括写关注错误。
-
# wtimeout? ⇒ true | false
错误是否为写关注(write concern)超时。
Mongo::Error::ReadWriteRetryable 中包含的方法
#retryable? , #write_retryable?
Mongo::Error::SdamErrorDetection 中包含的方法
#node_recovering? , #node_shutting_down? , #not_master?
实例属性详细信息
# code ⇒整数(只读)
返回值 从文档中解析出的错误代码。
43 44 45 |
# File 'lib/ Mongo/error/operation_failure.rb', line 43 def 代码 @code end |
# code_name ⇒ string (只读)
返回值 从文档中解析出的错误代码名称。
48 49 50 |
# File 'lib/ Mongo/error/operation_failure.rb', line 48 def code_name @code_name end |
#详细信息⇒ string | nil (只读)
返回 错误的详细信息。对于 WriteConcernErrors,此值为 document['writeConcernError']['errInfo']。对于 WriteErrors,此值为 document['writeErrors'][0]['errInfo']。对于所有其他错误,该值为零。
151 152 153 |
# File 'lib/ Mongo/error/operation_failure.rb', line 151 def 详情 @details end |
# 文档 =" BSON::Document | nil (只读)
返回值 服务器返回的错误文档。
156 157 158 |
# File 'lib/ Mongo/error/operation_failure.rb', line 156 def 文档 @document end |
# 结果 ⇒ 操作::结果(只读)
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回操作的结果对象。
161 162 163 |
# File 'lib/ Mongo/error/operation_failure.rb', line 161 def 结果 @result end |
# server_message ⇒ string (只读)
返回值 从响应中解析出的服务器返回的错误消息。
54 55 56 |
# File 'lib/ Mongo/error/operation_failure.rb', line 54 def @server_message end |
# write_concern_error_code ⇒整数 | nil (只读)
如果存在写关注错误并具有代码,则返回该写关注错误的错误代码。
139 140 141 |
# File 'lib/ Mongo/error/operation_failure.rb', line 139 def write_concern_error_code @write_concern_error_code end |
# write_concern_error_code_name ⇒ string | nil (只读)
返回 如果写关注错误存在且具有代码名称,则为写关注错误的代码名称。
145 146 147 |
# File 'lib/ Mongo/error/operation_failure.rb', line 145 def write_concern_error_code_name @write_concern_error_code_name end |
# write_concern_error_document ⇒哈希 | nil (只读)
返回服务器报告的写关注错误文档(如果有)。
133 134 135 |
# File 'lib/ Mongo/error/operation_failure.rb', line 133 def write_concern_error_document @write_concern_error_document end |
实例方法详细信息
# change_stream_resumable? ⇒ true , false
如果触发此错误的操作是 getMore,是否可以恢复发生此错误的变更流?
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ Mongo/error/operation_failure.rb', line 96 def change_stream_resumable? if @result && @result.is_a?(mongo::操作::getMore::结果) # CursorNotFound 异常始终是可恢复的,因为服务器 # 不知道游标 ID,因此无法确定是否 # 游标是变更流,无法添加 # ResumableChangeStreamError 标签。 return true if 代码 == 43 # 对于未确认的写入,不会填充连接描述。 if connection_description.max_wire_version >= 9 标签?('ResumableChangeStreamError') else change_stream_resumable_code? end else false end end |
# connection_description ⇒ Server::Description
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回执行此异常所指操作的服务器的MongoDB Server描述。
38 |
# File 'lib/ Mongo/error/operation_failure.rb', line 38 def_delegator :@result, :connection_description |
#initialize (message = nil, result = nil, options = {}) ⇒ 对象
创建操作失败。
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/ Mongo/error/operation_failure.rb', line 186 def 初始化( = nil, 结果 = nil, = {}) @details = retrieve_details([:文档]) 超(append_details(, @details)) @result = 结果 @code = [:code] @code_name = [:code_name] @write_concern_error_document = [:write_concern_error_document] @write_concern_error_code = [:write_concern_error_code] @write_concern_error_code_name = [:write_concern_error_code_name] @write_concern_error_labels = [:write_concern_error_labels] || [] @labels = [:labels] || [] @wtimeout = !![:wtimeout] @document = [:文档] @server_message = [:server_message] end |
# max_time_ms_expired? ⇒ true | false
错误是否为 MaxTimeMSExpired。
217 218 219 |
# File 'lib/ Mongo/error/operation_failure.rb', line 217 def max_time_ms_expired? 代码 == 50 # MaxTimeMSExpired end |
# write_concern_error? ⇒ true | false
返回此故障是否包括写关注(write concern)错误。 故障可能具有顶级错误和写关注(write concern)错误,或两者之一。
125 126 127 |
# File 'lib/ Mongo/error/operation_failure.rb', line 125 def write_concern_error? !!@write_concern_error_document end |
# wtimeout? ⇒ true | false
错误是否为写关注(write concern)超时。
208 209 210 |
# File 'lib/ Mongo/error/operation_failure.rb', line 208 def wtimeout? @wtimeout end |