Class: CI::Queue::Redis::Supervisor
- Defined in:
- lib/ci/queue/redis/supervisor.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::CONNECTION_ERRORS, Base::TEN_MINUTES
Constants included from Common
Instance Attribute Summary
Attributes included from Common
Instance Method Summary collapse
Methods inherited from Base
#boot_heartbeat_process!, #created_at=, #custom_config, #custom_middlewares, #ensure_heartbeat_thread_alive!, #exhausted?, #expired?, #increment_test_failed, #initialize, #max_test_failed?, #progress, #queue_initialized?, #queue_initializing?, #reconnect_attempts, #remaining, #running, #size, #stop_heartbeat!, #test_failed, #to_a, #wait_for_master, #with_heartbeat, #workers_count
Methods included from Common
#distributed?, #flaky?, #release!, #report_failure!, #report_success!, #rescue_connection_errors, #retrying?
Constructor Details
This class inherits a constructor from CI::Queue::Redis::Base
Instance Method Details
#build ⇒ Object
16 17 18 |
# File 'lib/ci/queue/redis/supervisor.rb', line 16 def build @build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config) end |
#master? ⇒ Boolean
7 8 9 |
# File 'lib/ci/queue/redis/supervisor.rb', line 7 def master? false end |
#total ⇒ Object
11 12 13 14 |
# File 'lib/ci/queue/redis/supervisor.rb', line 11 def total wait_for_master(timeout: config.queue_init_timeout) redis.get(key('total')).to_i end |
#wait_for_workers ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ci/queue/redis/supervisor.rb', line 20 def wait_for_workers duration = measure do wait_for_master(timeout: config.queue_init_timeout) end yield if block_given? time_left = config.report_timeout - duration.to_i time_left_with_no_workers = config.inactive_workers_timeout until exhausted? || time_left <= 0 || max_test_failed? || time_left_with_no_workers <= 0 time_left -= 1 sleep 1 if active_workers? time_left_with_no_workers = config.inactive_workers_timeout else time_left_with_no_workers -= 1 end yield if block_given? end puts "Aborting, it seems all workers died." if time_left_with_no_workers <= 0 exhausted? rescue CI::Queue::Redis::LostMaster false end |