Class: QueueingProxy::Worker::Upstream
- Inherits:
-
Object
- Object
- QueueingProxy::Worker::Upstream
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/queueing_proxy/worker.rb
Overview
Defferable upstream connection
Defined Under Namespace
Modules: Client
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#port ⇒ Object
Returns the value of attribute port.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(payload, host, port, timeout, logger) ⇒ Upstream
constructor
A new instance of Upstream.
-
#request ⇒ Object
Connect to the upstream server and send the HTTP payload.
Constructor Details
#initialize(payload, host, port, timeout, logger) ⇒ Upstream
Returns a new instance of Upstream.
104 105 106 107 |
# File 'lib/queueing_proxy/worker.rb', line 104 def initialize(payload, host, port, timeout, logger) @response = Http::Parser.new @payload, @host, @port, @timeout, @logger = payload, host, port, timeout, logger end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
101 102 103 |
# File 'lib/queueing_proxy/worker.rb', line 101 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
101 102 103 |
# File 'lib/queueing_proxy/worker.rb', line 101 def logger @logger end |
#payload ⇒ Object
Returns the value of attribute payload.
101 102 103 |
# File 'lib/queueing_proxy/worker.rb', line 101 def payload @payload end |
#port ⇒ Object
Returns the value of attribute port.
101 102 103 |
# File 'lib/queueing_proxy/worker.rb', line 101 def port @port end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
102 103 104 |
# File 'lib/queueing_proxy/worker.rb', line 102 def response @response end |
#timeout ⇒ Object
Returns the value of attribute timeout.
101 102 103 |
# File 'lib/queueing_proxy/worker.rb', line 101 def timeout @timeout end |
Instance Method Details
#request ⇒ Object
Connect to the upstream server and send the HTTP payload
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/queueing_proxy/worker.rb', line 110 def request begin EventMachine.connect(host, port, Client) {|c| c.upstream = self c.comm_inactivity_timeout = timeout c.pending_connect_timeout = timeout } # TODO - Is this async/deferrable? rescue => e logger.error e fail # If something explodes here, fail the defferable end self end |