Class: RedisHA::ConnectionPool
- Inherits:
-
Object
- Object
- RedisHA::ConnectionPool
- Defined in:
- lib/redis_ha/connection_pool.rb
Constant Summary collapse
- DEFAULT_READ_TIMEOUT =
timeout after which a redis connection is considered down. the default is 500ms
0.5
- DEFAULT_RETRY_TIMEOUT =
timeout after which a redis that was marked as down is retried the default is 5s
5
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retry_timeout ⇒ Object
Returns the value of attribute retry_timeout.
Instance Method Summary collapse
- #connect(*conns) ⇒ Object
-
#initialize ⇒ ConnectionPool
constructor
A new instance of ConnectionPool.
- #method_missing(*msg) ⇒ Object
Constructor Details
#initialize ⇒ ConnectionPool
Returns a new instance of ConnectionPool.
13 14 15 16 17 18 |
# File 'lib/redis_ha/connection_pool.rb', line 13 def initialize @read_timeout = DEFAULT_READ_TIMEOUT @retry_timeout = DEFAULT_RETRY_TIMEOUT @connections = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
11 12 13 |
# File 'lib/redis_ha/connection_pool.rb', line 11 def connections @connections end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
11 12 13 |
# File 'lib/redis_ha/connection_pool.rb', line 11 def read_timeout @read_timeout end |
#retry_timeout ⇒ Object
Returns the value of attribute retry_timeout.
11 12 13 |
# File 'lib/redis_ha/connection_pool.rb', line 11 def retry_timeout @retry_timeout end |
Instance Method Details
#connect(*conns) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/redis_ha/connection_pool.rb', line 20 def connect(*conns) conns.each do |conn| @connections << RedisHA::Connection.new(conn, self) @connections.last.yield_connect end end |