Sha256: 26666933b76ab4c75330dd9b4c3ff95758bb3218ce5eceb1373f4c2f1bf32491

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
module Moped
  module Failover

    # Retry is for the case when we get exceptions around the connection, and
    # want to make another attempt to try and resolve the issue.
    #
    # @since 2.0.0
    module Retry
      extend self

      # Executes the failover strategy. In the case of retyr, we disconnect and
      # reconnect, then try the operation one more time.
      #
      # @example Execute the retry strategy.
      #   Moped::Failover::Retry.execute(exception, node)
      #
      # @param [ Exception ] exception The raised exception.
      # @param [ Node ] node The node the exception got raised on.
      #
      # @raise [ Errors::ConnectionFailure ] If the retry fails.
      #
      # @return [ Object ] The result of the block yield.
      #
      # @since 2.0.0
      def execute(exception, node)
        node.disconnect
        begin
          node.connection do |conn|
            yield(conn) if block_given?
          end
        rescue Exception => e
          node.down!
          raise(e)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
moped-2.0.6 lib/moped/failover/retry.rb
moped-2.0.5 lib/moped/failover/retry.rb
moped-2.0.4 lib/moped/failover/retry.rb
moped-2.0.3 lib/moped/failover/retry.rb
moped-2.0.2 lib/moped/failover/retry.rb
moped-2.0.1 lib/moped/failover/retry.rb
moped-2.0.0 lib/moped/failover/retry.rb
moped-2.0.0.rc2 lib/moped/failover/retry.rb
moped-2.0.0.rc1 lib/moped/failover/retry.rb
moped-2.0.0.beta6 lib/moped/failover/retry.rb
moped-2.0.0.beta5 lib/moped/failover/retry.rb
moped-2.0.0.beta4 lib/moped/failover/retry.rb