Class: Contrast::Api::Communication::Speedracer
- Includes:
- ServiceLifecycle, Components::Interface
- Defined in:
- lib/contrast/api/communication/speedracer.rb
Overview
Wraps all connection data to speedracer
Instance Attribute Summary collapse
-
#ensure_running ⇒ Object
readonly
Returns the value of attribute ensure_running.
-
#response_processor ⇒ Object
readonly
Returns the value of attribute response_processor.
-
#socket_client ⇒ Object
readonly
Returns the value of attribute socket_client.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #ensure_startup! ⇒ Object
-
#initialize ⇒ Speedracer
constructor
A new instance of Speedracer.
- #process_internally(event) ⇒ Object
- #return_response(event) ⇒ Object
Methods included from Components::Interface
Methods included from ServiceLifecycle
#attempt_local_service_startup, #determine_startup_options, #service_starter_thread, #spawn_service, #zombie_check
Constructor Details
#initialize ⇒ Speedracer
Returns a new instance of Speedracer.
17 18 19 20 21 22 |
# File 'lib/contrast/api/communication/speedracer.rb', line 17 def initialize @status = Contrast::Api::Communication::ConnectionStatus.new @socket_client = Contrast::Api::Communication::SocketClient.new @response_processor = Contrast::Api::Communication::ResponseProcessor.new @ensure_running = Mutex.new end |
Instance Attribute Details
#ensure_running ⇒ Object (readonly)
Returns the value of attribute ensure_running.
15 16 17 |
# File 'lib/contrast/api/communication/speedracer.rb', line 15 def ensure_running @ensure_running end |
#response_processor ⇒ Object (readonly)
Returns the value of attribute response_processor.
15 16 17 |
# File 'lib/contrast/api/communication/speedracer.rb', line 15 def response_processor @response_processor end |
#socket_client ⇒ Object (readonly)
Returns the value of attribute socket_client.
15 16 17 |
# File 'lib/contrast/api/communication/speedracer.rb', line 15 def socket_client @socket_client end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
15 16 17 |
# File 'lib/contrast/api/communication/speedracer.rb', line 15 def status @status end |
Instance Method Details
#ensure_startup! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/contrast/api/communication/speedracer.rb', line 24 def ensure_startup! return if status.connected? ensure_running.synchronize do if CONTRAST_SERVICE.use_bundled_service? logger.info('Attempting to start local service') unless attempt_local_service_startup logger.error('Failed to start local service') return end end unless status. startup_responses = return false unless startup_responses startup_responses.each { |response| response_processor.process(response) } end end end |
#process_internally(event) ⇒ Object
50 51 52 53 54 |
# File 'lib/contrast/api/communication/speedracer.rb', line 50 def process_internally event send_to_speedracer(event) do |response| response_processor.process(response) end end |
#return_response(event) ⇒ Object
44 45 46 47 48 |
# File 'lib/contrast/api/communication/speedracer.rb', line 44 def return_response event send_to_speedracer(event) do |response| return response end end |