Class: EventMachine::ProxyServer::Backend
- Inherits:
-
Connection
- Object
- Connection
- EventMachine::ProxyServer::Backend
- Defined in:
- lib/em-proxy/backend.rb
Instance Attribute Summary collapse
-
#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(reason = nil) ⇒ 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 |
# File 'lib/em-proxy/backend.rb', line 6 def initialize(debug = false) @debug = debug @connected = EM::DefaultDeferrable.new end |
Instance Attribute Details
#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
11 12 13 14 15 |
# File 'lib/em-proxy/backend.rb', line 11 def connection_completed debug [@name, :conn_complete] @plexer.connected(@name) @connected.succeed end |
#receive_data(data) ⇒ Object
17 18 19 20 |
# File 'lib/em-proxy/backend.rb', line 17 def receive_data(data) debug [@name, 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
24 25 26 |
# File 'lib/em-proxy/backend.rb', line 24 def send(data) @connected.callback { send_data data } end |
#unbind(reason = nil) ⇒ Object
Notify upstream plexer that the backend server is done processing the request
30 31 32 33 |
# File 'lib/em-proxy/backend.rb', line 30 def unbind(reason = nil) debug [@name, :unbind, reason] @plexer.unbind_backend(@name) end |