Class: Orchestrator::Service::TransportHttp
- Inherits:
-
Object
- Object
- Orchestrator::Service::TransportHttp
- Defined in:
- lib/orchestrator/service/transport_http.rb
Instance Method Summary collapse
-
#initialize(manager, processor) ⇒ TransportHttp
constructor
A new instance of TransportHttp.
- #terminate ⇒ Object
- #transmit(cmd) ⇒ Object
Constructor Details
#initialize(manager, processor) ⇒ TransportHttp
Returns a new instance of TransportHttp.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/orchestrator/service/transport_http.rb', line 5 def initialize(manager, processor) @manager = manager @settings = @manager.settings @processor = processor # Load http endpoint after module has had a chance to update the config config = @processor.config config[:tls] ||= @settings.tls config[:tokenize] = false @server = UV::HttpEndpoint.new @settings.uri, config @manager.thread.next_tick do # Call connected (we only need to do this once) # We may never be connected, this is just to signal that we are ready @processor.connected end end |
Instance Method Details
#terminate ⇒ Object
49 50 51 52 |
# File 'lib/orchestrator/service/transport_http.rb', line 49 def terminate @terminated = true @server.close_connection(:after_writing) end |
#transmit(cmd) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/orchestrator/service/transport_http.rb', line 23 def transmit(cmd) return if @terminated # TODO:: Support multiple simultaneous requests (multiple servers) @server.request(cmd[:method], cmd).then( proc { |result| # Make sure the request information is always available result[:request] = cmd @processor.buffer(result) nil }, proc { |failure| # Fail fast (no point waiting for the timeout) if @processor.queue.waiting #== cmd @processor.__send__(:resp_failure, :failed) end # TODO:: Log failure with more detail nil } ) nil end |