Class: BatsdDash::ConnectionPool
- Inherits:
-
Object
- Object
- BatsdDash::ConnectionPool
- Defined in:
- lib/batsd-dash/connection_pool.rb
Defined Under Namespace
Classes: Client
Class Attribute Summary collapse
-
.pool ⇒ Object
readonly
Returns the value of attribute pool.
-
.settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
- .close_connection_pool ⇒ Object
- .initialize_connection_pool ⇒ Object
- .start_reconnect_timer ⇒ Object
Class Attribute Details
.pool ⇒ Object (readonly)
Returns the value of attribute pool.
11 12 13 |
# File 'lib/batsd-dash/connection_pool.rb', line 11 def pool @pool end |
.settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/batsd-dash/connection_pool.rb', line 10 def settings @settings end |
Class Method Details
.close_connection_pool ⇒ Object
33 34 35 36 |
# File 'lib/batsd-dash/connection_pool.rb', line 33 def close_connection_pool @pool.close if @pool @pool = nil end |
.initialize_connection_pool ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/batsd-dash/connection_pool.rb', line 13 def initialize_connection_pool # default settings (which are defaults from batsd itself) @settings ||= { host: 'localhost', port: 8127, pool_size: 4 } if @reconnect_timer @reconnect_timer.cancel @reconnect_timer = nil end begin @pool = EventMachine::Synchrony::ConnectionPool.new(size: settings[:pool_size]) do Client.new(settings[:host], settings[:port]) end rescue Exception => e warn "Connection Pool Error: #{e.}" end end |
.start_reconnect_timer ⇒ Object
38 39 40 41 42 43 |
# File 'lib/batsd-dash/connection_pool.rb', line 38 def start_reconnect_timer unless @reconnect_timer # try to reconnect every 30 seconds @reconnect_timer = EventMachine::Synchrony.add_timer(30) { initialize_connection_pool } end end |