Class: KumoDockerCloud::HaproxyEventHandler
- Inherits:
-
Object
- Object
- KumoDockerCloud::HaproxyEventHandler
- Defined in:
- lib/kumo_dockercloud/haproxy_event_handler.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize ⇒ HaproxyEventHandler
constructor
A new instance of HaproxyEventHandler.
- #on_close ⇒ Object
- #on_error ⇒ Object
- #on_message ⇒ Object
- #on_open ⇒ Object
Constructor Details
#initialize ⇒ HaproxyEventHandler
Returns a new instance of HaproxyEventHandler.
5 6 7 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 5 def initialize @data = '' end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 3 def data @data end |
Instance Method Details
#on_close ⇒ Object
21 22 23 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 21 def on_close Proc.new { |_event| EventMachine.stop } end |
#on_error ⇒ Object
17 18 19 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 17 def on_error Proc.new { |event| raise HaproxySocketError.new(event.) } end |
#on_message ⇒ Object
13 14 15 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 13 def Proc.new { |event| @data << JSON.parse(event.data)['output'] } end |
#on_open ⇒ Object
9 10 11 |
# File 'lib/kumo_dockercloud/haproxy_event_handler.rb', line 9 def on_open Proc.new { |_event| @data = '' } end |