Module: SolidCacheMongoid::Store::Failsafe

Included in:
SolidCacheMongoid::Store
Defined in:
lib/solid_cache_mongoid/store/failsafe.rb

Constant Summary collapse

TRANSIENT_MONGOID_ERRORS =
[
  ::Mongo::Error::SocketError,
  ::Mongo::Error::SocketTimeoutError,
  ::Mongo::Error::NoServerAvailable,
  ::Mongo::Error::OperationFailure,
  ::Mongo::Error::TimeoutError,
  ::Mongo::Error::ServerTimeoutError
]
DEFAULT_ERROR_HANDLER =
->(method:, returning:, exception:) do
  if Store.logger
    Store.logger.error { "SolidCacheStore: #{method} failed, returned #{returning.inspect}: #{exception.class}: #{exception.message}" }
  end
end

Instance Method Summary collapse

Instance Method Details

#initialize(options = {}) ⇒ Object



21
22
23
24
25
# File 'lib/solid_cache_mongoid/store/failsafe.rb', line 21

def initialize(options = {})
  super(options)

  @error_handler = options.fetch(:error_handler, DEFAULT_ERROR_HANDLER)
end