Class: CI::Queue::Redis::Supervisor

Inherits:
Base
  • Object
show all
Defined in:
lib/ci/queue/redis/supervisor.rb

Direct Known Subclasses

GrindSupervisor

Constant Summary

Constants inherited from Base

Base::CONNECTION_ERRORS, Base::TEN_MINUTES

Constants included from Common

Common::CONNECTION_ERRORS

Instance Attribute Summary

Attributes included from Common

#config

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

#buildObject



15
16
17
# File 'lib/ci/queue/redis/supervisor.rb', line 15

def build
  @build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config)
end

#master?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/ci/queue/redis/supervisor.rb', line 6

def master?
  false
end

#totalObject



10
11
12
13
# File 'lib/ci/queue/redis/supervisor.rb', line 10

def total
  wait_for_master(timeout: config.queue_init_timeout)
  redis.get(key('total')).to_i
end

#wait_for_workersObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ci/queue/redis/supervisor.rb', line 19

def wait_for_workers
  wait_for_master(timeout: config.queue_init_timeout)

  yield if block_given?

  time_left = config.report_timeout
  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