123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Retryable::BaseWorker Private

Do not use. This class is for internal use only.
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.

Since:

  • 2.1.0

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#retryableMongo::Retryable (readonly)

Returns:

  • (Mongo::Retryable)

    retryable A reference to the client object that instatiated this worker.

Since:

  • 2.1.0

[ GitHub ]

  
# 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.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/retryable/base_worker.rb', line 100

def deprecation_warning(key, warning)
  $_deprecation_warnings ||= {}
  unless $_deprecation_warnings[key]
    $_deprecation_warnings[key] = true
    Logger.logger.warn(warning)
  end
end

#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.

Returns:

  • (true | false)

    true if the exception is retryable.

Since:

  • 2.1.0

[ GitHub ]

  
# 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.

Returns:

  • (true | false)

    true if the exception is retryable.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/retryable/base_worker.rb', line 87

def is_retryable_exception?(e)
  retryable_exceptions.any? { |klass| klass === e }
end

#legacy_retryable_exceptionsArray<Mongo:Error> (private)

Indicate which exception classes that are generally retryable when using legacy retries mechanism.

Returns:

  • (Array<Mongo:Error>)

    Array of exception classes that are considered retryable.

Since:

  • 2.1.0

[ GitHub ]

  
# 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.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/retryable/base_worker.rb', line 109

def log_retry(e, options = nil)
  message = (options || {}).fetch(:message, "Retry")
  Logger.logger.warn "#{message} due to: #{e.class.name}: #{e.message}"
end

#retryable_exceptionsArray<Mongo:Error> (private)

Indicate which exception classes that are generally retryable when using modern retries mechanism.

Returns:

  • (Array<Mongo:Error>)

    Array of exception classes that are considered retryable.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/retryable/base_worker.rb', line 57

def retryable_exceptions
  [
    Error::ConnectionPerished,
    Error::ServerNotUsable,
    Error::SocketError,
    Error::SocketTimeoutError,
  ].freeze
end