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 75

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

#is_retryable_exception?(e) ⇒ true | false (private)

Tests to see if the given exception instance is of a type that can be retried.

Returns:

  • (true | false)

    true if the exception is retryable.

Since:

  • 2.1.0

[ GitHub ]

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

def is_retryable_exception?(e)
  retryable_exceptions.any? { |klass| klass === e }
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 84

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.

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 56

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