Class: Mongo::Retryable::BaseWorker Private
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
Mongo::Retryable::ReadWorker, Mongo::Retryable::WriteWorker
|
|
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Forwardable
|
|
| Inherits: | Object |
| Defined in: | lib/mongo/retryable/base_worker.rb |
Overview
The abstract superclass for workers employed by ::Mongo::Retryable.
Class Method Summary
-
.new(retryable) ⇒ BaseWorker
constructor
Internal use only
Constructs a new worker.
Instance Attribute Summary
- #retryable ⇒ Mongo::Retryable readonly Internal use only
Instance Method Summary
-
#deprecation_warning(key, warning)
private
Internal use only
Logs the given deprecation warning the first time it is called for a given key; after that, it does nothing when given the same key.
-
#is_legacy_retryable_exception?(e) ⇒ true | false
private
Internal use only
Tests to see if the given exception instance is of a type that can be retried with legacy retry mechanism.
-
#is_retryable_exception?(e) ⇒ true | false
private
Internal use only
Tests to see if the given exception instance is of a type that can be retried with modern retry mechanism.
-
#legacy_retryable_exceptions ⇒ Array<Mongo:Error>
private
Internal use only
Indicate which exception classes that are generally retryable when using legacy retries mechanism.
-
#log_retry(e, options = nil)
private
Internal use only
Log a warning so that any application slow down is immediately obvious.
-
#overload_error?(e) ⇒ true | false
private
Internal use only
Whether the error indicates server overload.
-
#retry_policy ⇒ Mongo::Retryable::RetryPolicy
private
Internal use only
Returns the retry policy from the client.
-
#retryable_exceptions ⇒ Array<Mongo:Error>
private
Internal use only
Indicate which exception classes that are generally retryable when using modern retries mechanism.
-
#retryable_overload_error?(e) ⇒ true | false
private
Internal use only
Whether the error is a retryable overload error.
Instance Attribute Details
#retryable ⇒ Mongo::Retryable (readonly)
# File 'lib/mongo/retryable/base_worker.rb', line 34
attr_reader :retryable
Instance Method Details
#deprecation_warning(key, warning) (private)
Logs the given deprecation warning the first time it is called for a given key; after that, it does nothing when given the same key.
#is_legacy_retryable_exception?(e) ⇒ true | false (private)
Tests to see if the given exception instance is of a type that can be retried with legacy retry mechanism.
# File 'lib/mongo/retryable/base_worker.rb', line 95
def is_legacy_retryable_exception?(e) legacy_retryable_exceptions.any? { |klass| klass === e } end
#is_retryable_exception?(e) ⇒ true | false (private)
Tests to see if the given exception instance is of a type that can be retried with modern retry mechanism.
# File 'lib/mongo/retryable/base_worker.rb', line 87
def is_retryable_exception?(e) retryable_exceptions.any? { |klass| klass === e } end
#legacy_retryable_exceptions ⇒ Array<Mongo:Error> (private)
Indicate which exception classes that are generally retryable when using legacy retries mechanism.
# File 'lib/mongo/retryable/base_worker.rb', line 71
def legacy_retryable_exceptions [ Error::ConnectionPerished, Error::ServerNotUsable, Error::SocketError, Error::SocketTimeoutError, Error::PoolClearedError, Error::PoolPausedError, ].freeze end
#log_retry(e, options = nil) (private)
Log a warning so that any application slow down is immediately obvious.
#overload_error?(e) ⇒ true | false (private)
Whether the error indicates server overload.
# File 'lib/mongo/retryable/base_worker.rb', line 127
def overload_error?(e) e.respond_to?(:label?) && e.label?('SystemOverloadedError') end
#retry_policy ⇒ Mongo::Retryable::RetryPolicy (private)
Returns the retry policy from the client.
# File 'lib/mongo/retryable/base_worker.rb', line 117
def retry_policy client.retry_policy end
#retryable_exceptions ⇒ Array<Mongo:Error> (private)
Indicate which exception classes that are generally retryable when using modern retries mechanism.
# File 'lib/mongo/retryable/base_worker.rb', line 57
def retryable_exceptions [ Error::ConnectionPerished, Error::ServerNotUsable, Error::SocketError, Error::SocketTimeoutError, ].freeze end
#retryable_overload_error?(e) ⇒ true | false (private)
Whether the error is a retryable overload error. An error is retryable overload when it has both the SystemOverloadedError and RetryableError labels.
# File 'lib/mongo/retryable/base_worker.rb', line 138
def retryable_overload_error?(e) overload_error?(e) && e.respond_to?(:label?) && e.label?('RetryableError') end