Sha256: e76cd780bd2c77d1fe23f8597a5e839fd5913300021387e7b5faba283d85fdfc

Contents?: true

Size: 867 Bytes

Versions: 7

Compression:

Stored size: 867 Bytes

Contents

module FreshConnection
  class AbstractConnectionManager
    EXCEPTION_MESSAGE_WHEN_SLAVE_SERVER_DOWN = [
      "MySQL server has gone away",
      "closed MySQL connection",
      "Can't connect to local MySQL server"
    ].map{|msg| Regexp.escape(msg)}.join("|")

    attr_reader :slave_group

    def initialize(slave_group = "slave")
      @mutex = Mutex.new
      @slave_group = (slave_group.presence || "slave").to_s
    end

    def slave_connection
    end

    def put_aside!
    end

    def recovery(failure_connection, exception)
      false
    end

    def recoverable?
      false
    end

    private

    def synchronize
      @mutex.synchronize{ yield }
    end

    def current_thread_id
      Thread.current.object_id
    end

    def slave_down_message?(message)
      /#{EXCEPTION_MESSAGE_WHEN_SLAVE_SERVER_DOWN}/o =~ message
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fresh_connection-0.2.6 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.5 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.4 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.3 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.2 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.1 lib/fresh_connection/abstract_connection_manager.rb
fresh_connection-0.2.0 lib/fresh_connection/abstract_connection_manager.rb