fasten 0.8.0 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77fcc3eddc4f86d6b6a2ad36fbeb6f7edb302c6068b65df3dd61d2531e8251a
4
- data.tar.gz: 3638c6cf10144c9a47bedfca7ada81547c3f2b15a440a81b1c4b8a055bd38d3d
3
+ metadata.gz: 2c1260fd4b0ae5e2b82ec028a37a463d50aa0226ea08151b3095b1247280a1de
4
+ data.tar.gz: 3d2e0e59f36063da7d57930d29d341ab09cd85a831e81e6e3506f7151a3e27e6
5
5
  SHA512:
6
- metadata.gz: 2b0ca6dcec14736e254d66ce33f536f70982923d638403f7e3a4cb0c950e59e74727fb47d847d24a8f9a1a80ad594d0cbae9734ef3ef9bdd7e5cc6b12b913ea5
7
- data.tar.gz: b1e139f7a7f62677a581a47ca95959919430a13d338e0adf3731d13d2675cbbfeba9a3173d31a5659002da3635a254f6b59cb95060042d77a54cb2faf4359537
6
+ metadata.gz: f172e77abad01cd436f5cd29a377b955a65dfdfc96c2efb8aebff4e14cb8ee49d6c107ad2d7a61e415fa3190567c118353754dbad50a9ab640108babc0a5229b
7
+ data.tar.gz: edc13bf78878b9bc857ea192b34d03bf017a76424d0e2fe2814bc382724678acd007a8780dbd79f1eae70020e7eae4be1caf988caf9543f9bf1a7b93dbdacc9e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.1
1
+ ruby-2.5.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fasten (0.8.0)
4
+ fasten (0.8.4)
5
5
  binding_of_caller
6
6
  hirb
7
7
  os
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  rubocop
68
68
 
69
69
  BUNDLED WITH
70
- 1.17.1
70
+ 1.17.3
data/lib/fasten/runner.rb CHANGED
@@ -178,7 +178,7 @@ module Fasten
178
178
  end
179
179
 
180
180
  def show_error_tasks
181
- task_error_list.each do |task|
181
+ tasks.failed.each do |task|
182
182
  log_info "task: #{task} error:#{task.error}\n#{task.error&.backtrace&.join("\n")}"
183
183
  end
184
184
  end
@@ -188,7 +188,7 @@ module Fasten
188
188
 
189
189
  show_error_tasks
190
190
 
191
- message = "Stopping because the following tasks failed: #{task_error_list.map(&:to_s).join(', ')}"
191
+ message = "Stopping because the following tasks failed: #{tasks.failed.map(&:to_s).join(', ')}"
192
192
 
193
193
  if developer
194
194
  ui.cleanup
@@ -205,18 +205,20 @@ module Fasten
205
205
  end
206
206
 
207
207
  def remove_workers_as_needed
208
- while workers.count > jobs
209
- return unless (worker = workers.find { |item| item.running_task.nil? })
208
+ workers.group_by(&:class).each do |_clazz, worker_list|
209
+ while worker_list.count > jobs
210
+ break unless (worker = workers.find { |item| item.running_task.nil? })
210
211
 
211
- worker.kill
212
- workers.delete worker
212
+ worker.kill
213
+ workers.delete worker
213
214
 
214
- ui.force_clear
215
+ ui.force_clear
216
+ end
215
217
  end
216
218
  end
217
219
 
218
- def find_or_create_worker
219
- worker = workers.find { |item| item.running_task.nil? }
220
+ def find_or_create_worker(worker_class: )
221
+ worker = workers.find { |item| item.class == worker_class && item.running_task.nil? }
220
222
 
221
223
  unless worker
222
224
  @worker_id = (@worker_id || 0) + 1
@@ -234,9 +236,13 @@ module Fasten
234
236
 
235
237
  def dispatch_pending_tasks
236
238
  while tasks.waiting? && tasks.running.count < jobs
237
- worker = find_or_create_worker
238
-
239
239
  task = tasks.next
240
+
241
+ task_worker_class = task.worker_class || worker_class
242
+ task_worker_class = Object.const_get(task_worker_class) if task_worker_class.is_a? String
243
+
244
+ worker = find_or_create_worker worker_class: task_worker_class
245
+
240
246
  log_ini task, "on worker #{worker}"
241
247
  worker.send_request_to_child(task)
242
248
  tasks.running << task
data/lib/fasten/task.rb CHANGED
@@ -4,16 +4,17 @@ module Fasten
4
4
  class Task
5
5
  include Fasten::Support::State
6
6
 
7
- attr_accessor :name, :after, :shell, :ruby
7
+ attr_accessor :name, :after, :shell, :ruby, :worker_class
8
8
  attr_accessor :dependants, :depends, :request, :response, :worker, :run_score, :block
9
9
 
10
- def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil)
10
+ def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, worker_class: nil)
11
11
  self.name = name
12
12
  self.shell = shell
13
13
  self.ruby = ruby
14
14
  self.block = block
15
15
  self.request = request
16
16
  self.after = after
17
+ self.worker_class = worker_class
17
18
  end
18
19
 
19
20
  def marshal_dump
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fasten
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-22 00:00:00.000000000 Z
11
+ date: 2018-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.7.6
216
+ rubygems_version: 2.7.8
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Fasten your seatbelts! Run jobs in parallel, intelligently.