fasten 0.12.2 → 0.12.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fasten/defaults.rb +4 -0
- data/lib/fasten/runner.rb +4 -4
- data/lib/fasten/task_manager.rb +17 -6
- data/lib/fasten/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3529d50d7d2bc28cb85f1c41828504cf602b8b04b066e7a3ab11ec2102c6aee0
|
4
|
+
data.tar.gz: f68633c37fc30cded6460bf7093ca010d6d214f4d04ed592bc938e078eb8a1b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d7afa32077b61a6c4d2f14966eee04925bab79b63e4fb297ab64426aabf74def1e7e67ce48c35d58e6d5e883ca112e73d7b37d616c338a4b7d11d618df30919
|
7
|
+
data.tar.gz: 2b662abc55dc8f6a3248e4b67959c52240b6f27635719295b87dfb794e7d40f8c4573716137ea22a01f7b9076dcdc79c515d9b326692a72bd4696026278f3c18
|
data/Gemfile.lock
CHANGED
data/lib/fasten/defaults.rb
CHANGED
data/lib/fasten/runner.rb
CHANGED
@@ -18,21 +18,21 @@ module Fasten
|
|
18
18
|
include Fasten::Support::UI
|
19
19
|
include Fasten::Support::Yaml
|
20
20
|
|
21
|
-
attr_accessor :name, :stats, :summary, :jobs, :worker_class, :fasten_dir, :use_threads, :ui_mode, :developer, :workers, :queue, :tasks
|
21
|
+
attr_accessor :name, :stats, :summary, :jobs, :worker_class, :fasten_dir, :use_threads, :ui_mode, :developer, :workers, :queue, :tasks, :priority
|
22
22
|
|
23
23
|
def initialize(**options)
|
24
|
-
%i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer].each do |key|
|
24
|
+
%i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer priority].each do |key|
|
25
25
|
options[key] = Fasten.send "default_#{key}" unless options.key? key
|
26
26
|
end
|
27
27
|
|
28
|
-
@tasks = TaskManager.new(targets: options[:targets] || [])
|
28
|
+
@tasks = TaskManager.new(targets: options[:targets] || [], runner: self)
|
29
29
|
@workers = []
|
30
30
|
|
31
31
|
reconfigure(options)
|
32
32
|
end
|
33
33
|
|
34
34
|
def reconfigure(**options)
|
35
|
-
%i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer].each do |key|
|
35
|
+
%i[name stats summary jobs worker_class fasten_dir use_threads ui_mode developer priority].each do |key|
|
36
36
|
send "#{key}=", options[key] if options.key? key
|
37
37
|
end
|
38
38
|
|
data/lib/fasten/task_manager.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Fasten
|
2
2
|
class TaskManager < Array # rubocop:disable Metrics/ClassLength
|
3
|
-
attr_reader :done, :failed, :pending, :running, :targets
|
3
|
+
attr_reader :done, :failed, :pending, :running, :targets, :runner
|
4
4
|
|
5
|
-
def initialize(targets: [])
|
5
|
+
def initialize(targets: [], runner:)
|
6
6
|
super()
|
7
7
|
|
8
8
|
@map = {}
|
@@ -12,6 +12,7 @@ module Fasten
|
|
12
12
|
@running = []
|
13
13
|
@targets = targets
|
14
14
|
@waiting = nil
|
15
|
+
@runner = runner
|
15
16
|
end
|
16
17
|
|
17
18
|
def push(*items)
|
@@ -149,10 +150,20 @@ module Fasten
|
|
149
150
|
|
150
151
|
@pending -= to_move
|
151
152
|
@waiting += to_move
|
152
|
-
@
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
case @runner.priority
|
154
|
+
when :dependants
|
155
|
+
@waiting.sort_by!.with_index do |task, index|
|
156
|
+
task.state = :WAIT
|
157
|
+
[-task.run_score, index]
|
158
|
+
end
|
159
|
+
when :dependants_avg
|
160
|
+
@waiting.sort_by!.with_index do |task, index|
|
161
|
+
task.state = :WAIT
|
162
|
+
last_avg = task.last && task.last['avg'] || 0
|
163
|
+
[-task.run_score, -last_avg.to_f, index]
|
164
|
+
end
|
165
|
+
else
|
166
|
+
raise "Unknown priority #{@runner.priority}"
|
156
167
|
end
|
157
168
|
end
|
158
169
|
end
|
data/lib/fasten/version.rb
CHANGED