Module: Tlb::Balancer
- Defined in:
- lib/tlb.rb
Constant Summary collapse
- TLB_BALANCER_PORT =
'TLB_BALANCER_PORT'
- BALANCE_PATH =
'/balance'
- SUITE_TIME_REPORTING_PATH =
'/suite_time'
- SUITE_RESULT_REPORTING_PATH =
'/suite_result'
Class Method Summary collapse
- .get(path) ⇒ Object
- .host ⇒ Object
- .port ⇒ Object
- .running? ⇒ Boolean
- .send(path, data) ⇒ Object
- .terminate ⇒ Object
- .wait_for_start ⇒ Object
Class Method Details
.get(path) ⇒ Object
37 38 39 |
# File 'lib/tlb.rb', line 37 def self.get path Net::HTTP.get_response(host, path, port).body end |
.host ⇒ Object
21 22 23 |
# File 'lib/tlb.rb', line 21 def self.host 'localhost' end |
.port ⇒ Object
25 26 27 |
# File 'lib/tlb.rb', line 25 def self.port ENV[TLB_BALANCER_PORT] || '8019' end |
.running? ⇒ Boolean
41 42 43 44 45 |
# File 'lib/tlb.rb', line 41 def self.running? get("/control/status") == "RUNNING" rescue false end |
.send(path, data) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/tlb.rb', line 29 def self.send path, data Net::HTTP.start(host, port) do |h| res = h.post(path, data) res.value res.body end end |
.terminate ⇒ Object
47 48 49 |
# File 'lib/tlb.rb', line 47 def self.terminate get("/control/suicide") end |
.wait_for_start ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/tlb.rb', line 51 def self.wait_for_start loop do begin break if running? rescue #ignore end end end |