Module: QueueingProxy::Worker::Upstream::Client
- Defined in:
- lib/queueing_proxy/worker.rb
Overview
The connection handler for EM.
Instance Attribute Summary collapse
-
#upstream ⇒ Object
Returns the value of attribute upstream.
Instance Method Summary collapse
-
#connection_completed ⇒ Object
Succesful connection!.
-
#receive_data(data) ⇒ Object
Read the response of the upstream proxy.
-
#unbind ⇒ Object
If something bad happens to the connection, bind gets called.
Instance Attribute Details
#upstream ⇒ Object
Returns the value of attribute upstream.
70 71 72 |
# File 'lib/queueing_proxy/worker.rb', line 70 def upstream @upstream end |
Instance Method Details
#connection_completed ⇒ Object
Succesful connection!
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/queueing_proxy/worker.rb', line 73 def connection_completed # Setup our callback for when the upstream response hits us upstream.response.on_headers_complete = Proc.new { upstream.succeed close_connection :stop } # Send the HTTP request upstream send_data upstream.payload end |
#receive_data(data) ⇒ Object
Read the response of the upstream proxy
86 87 88 89 90 91 92 93 |
# File 'lib/queueing_proxy/worker.rb', line 86 def receive_data(data) begin upstream.response << data rescue HTTP::Parser::Error upstream.fail close_connection end end |
#unbind ⇒ Object
If something bad happens to the connection, bind gets called
96 97 98 |
# File 'lib/queueing_proxy/worker.rb', line 96 def unbind upstream.fail end |