Class: FreshConnection::ConnectionManager

Inherits:
AbstractConnectionManager show all
Defined in:
lib/fresh_connection/connection_manager.rb

Constant Summary

Constants inherited from AbstractConnectionManager

AbstractConnectionManager::EXCEPTION_MESSAGE_WHEN_SLAVE_SERVER_DOWN

Instance Attribute Summary

Attributes inherited from AbstractConnectionManager

#slave_group

Instance Method Summary collapse

Methods inherited from AbstractConnectionManager

#initialize

Constructor Details

This class inherits a constructor from FreshConnection::AbstractConnectionManager

Instance Method Details

#put_aside!Object



11
12
13
14
15
16
17
# File 'lib/fresh_connection/connection_manager.rb', line 11

def put_aside!
  synchronize do
    if c = slave_connections.delete(current_thread_id)
      c.disconnect! rescue nil
    end
  end
end

#recoverable?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fresh_connection/connection_manager.rb', line 28

def recoverable?
  true
end

#recovery(failure_connection, exception) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/fresh_connection/connection_manager.rb', line 19

def recovery(failure_connection, exception)
  if recoverable? && slave_down_message?(exception.message)
    put_aside!
    true
  else
    false
  end
end

#slave_connectionObject



5
6
7
8
9
# File 'lib/fresh_connection/connection_manager.rb', line 5

def slave_connection
  synchronize do
    slave_connections[current_thread_id] ||= new_connection
  end
end