Class: EventMachine::ProxyServer::Backend
- Inherits:
-
Connection
- Object
- Connection
- EventMachine::ProxyServer::Backend
- Defined in:
- lib/em-proxy/backend.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#debug ⇒ Object
writeonly
Sets the attribute debug.
-
#name ⇒ Object
Returns the value of attribute name.
-
#plexer ⇒ Object
Returns the value of attribute plexer.
Instance Method Summary collapse
- #connection_completed ⇒ Object
-
#initialize(debug = false) ⇒ Backend
constructor
A new instance of Backend.
- #receive_data(data) ⇒ Object
-
#send(data) ⇒ Object
Buffer data until the connection to the backend server is established and is ready for use.
-
#unbind ⇒ Object
Notify upstream plexer that the backend server is done processing the request.
Constructor Details
#initialize(debug = false) ⇒ Backend
Returns a new instance of Backend.
6 7 8 9 10 |
# File 'lib/em-proxy/backend.rb', line 6 def initialize(debug = false) @debug = debug @connected = EM::DefaultDeferrable.new @data = [] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/em-proxy/backend.rb', line 4 def data @data end |
#debug=(value) ⇒ Object
Sets the attribute debug
4 5 6 |
# File 'lib/em-proxy/backend.rb', line 4 def debug=(value) @debug = value end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/em-proxy/backend.rb', line 4 def name @name end |
#plexer ⇒ Object
Returns the value of attribute plexer.
4 5 6 |
# File 'lib/em-proxy/backend.rb', line 4 def plexer @plexer end |
Instance Method Details
#connection_completed ⇒ Object
12 13 14 15 16 |
# File 'lib/em-proxy/backend.rb', line 12 def connection_completed debug [@name, :conn_complete] @plexer.connected(@name) @connected.succeed end |
#receive_data(data) ⇒ Object
18 19 20 21 22 |
# File 'lib/em-proxy/backend.rb', line 18 def receive_data(data) debug [@name, data] @data.push data @plexer.relay_from_backend(@name, data) end |
#send(data) ⇒ Object
Buffer data until the connection to the backend server is established and is ready for use
26 27 28 |
# File 'lib/em-proxy/backend.rb', line 26 def send(data) @connected.callback { send_data data } end |
#unbind ⇒ Object
Notify upstream plexer that the backend server is done processing the request
32 33 34 35 |
# File 'lib/em-proxy/backend.rb', line 32 def unbind debug [@name, :unbind] @plexer.unbind_backend(@name) end |