File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 5
5
6
6
# A variation of `Thread::Queue` that allows us to prioritise certain types of jobs.
7
7
class JobQueue
8
- def initialize ( queue_type )
8
+ def initialize ( queue_type , logger )
9
9
@mutex = Mutex . new
10
10
@queue = Hash . new { |h , k | h [ k ] = [ ] }
11
11
@queue_type = queue_type
12
12
@condvar = ConditionVariable . new
13
+ @logger = logger
13
14
end
14
15
15
16
def <<( job )
@@ -24,9 +25,12 @@ def pop
24
25
loop do
25
26
running_long_build_count = SharedState . instance . running_jobs ( @queue_type ) . count ( &:long_build? )
26
27
long_build_slots = QueueTypes . slots ( @queue_type ) / 2
28
+ @logger . call ( "Long builds: #{ running_long_build_count } running, #{ long_build_slots } available" )
27
29
28
30
if running_long_build_count < long_build_slots && !@queue [ :long ] . empty?
29
- break @queue [ :long ] . shift
31
+ job = @queue [ :long ] . shift
32
+ @logger . call ( "Long build slot available. Scheduling #{ job . runner_name } for deployment..." )
33
+ break job
30
34
elsif !@queue [ :default ] . empty?
31
35
break @queue [ :default ] . shift
32
36
else
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class OrkaStartProcessor < ThreadRunner
27
27
28
28
def initialize ( queue_type , name )
29
29
super ( "#{ self . class . name } (#{ name } )" )
30
- @queue = JobQueue . new ( queue_type )
30
+ @queue = JobQueue . new ( queue_type , method ( :log ) )
31
31
end
32
32
33
33
def pausable?
You can’t perform that action at this time.
0 commit comments