fasten 0.10.0 → 0.12.0

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: a4f1399b63f43e69c81204967541b3f37501f0eceaa29cdc1f559fe3cad2a624
4
- data.tar.gz: aa29489a9c7c516ba209c1ad9d4d777eb85829a4b2c050407778c312a4647f90
3
+ metadata.gz: a3685f6fe8763ef1686a29ce9c0c9fb5a78d6cf7ebb425d0bc4f5141b9f047a0
4
+ data.tar.gz: 0a6cbd8425207acd434317172de2d3fbf606874683d6dd3e52e1890cf7b41489
5
5
  SHA512:
6
- metadata.gz: d0553cc25064568b62ab6ff4b3ba63a8fc10c1d09493cfc0844758be24f509b9fd0ae372f335cbdc06facbb58159026b9526c694631d47250c625af91785c82c
7
- data.tar.gz: 99b50c0529c54ecd65adf2a4127fd744c9b240035178e476cfbdb0770c5ed4c7a8bbf1fc488b07e564e977060361924c4ebded669ed5f2583c29096f37099292
6
+ metadata.gz: e3c511e65ce64a818ad835c9c1b89b6991b2fec96b950cb08c8531a6c24bc711c9019a7888a1aeb781fbf6ba8f86854a8facc150d9b1bc76ff9e59fe3ffc08ba
7
+ data.tar.gz: e619759f57d2d1f287fa7ae4fba89f58f12a4b9e93934961691d00cb69fdddbc94a42756e8d95cc6a2a5f613da5cec393b5a717465f0f0c59a212ee5b6b66b7e
data/.rubocop.yml CHANGED
@@ -21,10 +21,12 @@ Style:
21
21
  Exclude:
22
22
  - 'lib/fasten/ui/curses.rb'
23
23
  Metrics/AbcSize:
24
- Max: 17
24
+ Max: 25
25
25
  Metrics/MethodLength:
26
26
  Max: 15
27
27
  Metrics/ParameterLists:
28
28
  Max: 8
29
29
  Layout/AlignHash:
30
30
  EnforcedHashRocketStyle: table
31
+ Style/FormatStringToken:
32
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fasten (0.8.8)
4
+ fasten (0.12.0)
5
5
  binding_of_caller
6
6
  hirb
7
7
  os
@@ -14,18 +14,17 @@ GEM
14
14
  binding_of_caller (0.8.0)
15
15
  debug_inspector (>= 0.0.1)
16
16
  coderay (1.1.2)
17
- curses (1.2.5)
17
+ curses (1.3.1)
18
18
  debug_inspector (0.0.3)
19
19
  diff-lcs (1.3)
20
20
  hirb (0.7.3)
21
- jaro_winkler (1.5.1)
22
- method_source (0.9.1)
21
+ jaro_winkler (1.5.3)
22
+ method_source (0.9.2)
23
23
  os (1.0.1)
24
- parallel (1.12.1)
25
- parser (2.5.3.0)
24
+ parallel (1.17.0)
25
+ parser (2.6.5.0)
26
26
  ast (~> 2.4.0)
27
- powerpack (0.1.2)
28
- pry (0.12.0)
27
+ pry (0.12.2)
29
28
  coderay (~> 1.1.0)
30
29
  method_source (~> 0.9.0)
31
30
  rainbow (3.0.0)
@@ -34,25 +33,24 @@ GEM
34
33
  rspec-core (~> 3.8.0)
35
34
  rspec-expectations (~> 3.8.0)
36
35
  rspec-mocks (~> 3.8.0)
37
- rspec-core (3.8.0)
36
+ rspec-core (3.8.2)
38
37
  rspec-support (~> 3.8.0)
39
- rspec-expectations (3.8.2)
38
+ rspec-expectations (3.8.5)
40
39
  diff-lcs (>= 1.2.0, < 2.0)
41
40
  rspec-support (~> 3.8.0)
42
- rspec-mocks (3.8.0)
41
+ rspec-mocks (3.8.2)
43
42
  diff-lcs (>= 1.2.0, < 2.0)
44
43
  rspec-support (~> 3.8.0)
45
- rspec-support (3.8.0)
46
- rubocop (0.60.0)
44
+ rspec-support (3.8.3)
45
+ rubocop (0.75.0)
47
46
  jaro_winkler (~> 1.5.1)
48
47
  parallel (~> 1.10)
49
- parser (>= 2.5, != 2.5.1.1)
50
- powerpack (~> 0.1)
48
+ parser (>= 2.6)
51
49
  rainbow (>= 2.2.2, < 4.0)
52
50
  ruby-progressbar (~> 1.7)
53
- unicode-display_width (~> 1.4.0)
54
- ruby-progressbar (1.10.0)
55
- unicode-display_width (1.4.0)
51
+ unicode-display_width (>= 1.4.0, < 1.7)
52
+ ruby-progressbar (1.10.1)
53
+ unicode-display_width (1.6.0)
56
54
 
57
55
  PLATFORMS
58
56
  ruby
data/lib/fasten.rb CHANGED
@@ -50,19 +50,19 @@ module Fasten
50
50
  puts "Fasten: loading #{path}"
51
51
  load path
52
52
  else
53
- STDERR.puts "Fasten: file/folder not found: #{path}"
53
+ warn "Fasten: file/folder not found: #{path}"
54
54
  exit 1
55
55
  end
56
56
  end
57
57
  end
58
58
 
59
- def opt_parser # rubocop:disable Metrics/MethodLength
59
+ def opt_parser # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
60
60
  return @opt_parser if defined? @opt_parser
61
61
 
62
62
  @options = { developer: false }
63
63
  @load_path = []
64
64
 
65
- @opt_parser = OptionParser.new do |opts|
65
+ @opt_parser = OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
66
66
  opts.banner = "Usage: #{$PROGRAM_NAME} [options] [targets]"
67
67
  opts.separator ''
68
68
  opts.separator 'Examples:'
data/lib/fasten/runner.rb CHANGED
@@ -11,7 +11,7 @@ require 'fasten/support/yaml'
11
11
  require 'fasten/timeout_queue'
12
12
 
13
13
  module Fasten
14
- class Runner
14
+ class Runner # rubocop:disable Metrics/ClassLength
15
15
  include Fasten::Support::Logger
16
16
  include Fasten::Support::State
17
17
  include Fasten::Support::Stats
@@ -217,7 +217,7 @@ module Fasten
217
217
  end
218
218
  end
219
219
 
220
- def find_or_create_worker(worker_class: )
220
+ def find_or_create_worker(worker_class:)
221
221
  worker = workers.find { |item| item.class == worker_class && item.running_task.nil? }
222
222
 
223
223
  unless worker
@@ -235,7 +235,7 @@ module Fasten
235
235
  end
236
236
 
237
237
  def dispatch_pending_tasks
238
- while tasks.waiting? && tasks.running.count < jobs
238
+ while tasks.waiting? && tasks.running.map(&:weight).sum < jobs
239
239
  task = tasks.next
240
240
 
241
241
  task_worker_class = task.worker_class || worker_class
@@ -16,7 +16,7 @@ module Fasten
16
16
  target.send :respond_to_missing?, name, include_private
17
17
  end
18
18
 
19
- def method_missing(method, *args, &block) # rubocop:disable MethodMissingSuper
19
+ def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper
20
20
  target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original
21
21
  target.send method, *args, &block
22
22
  end
@@ -18,8 +18,8 @@ module Fasten
18
18
  def kill
19
19
  log_info 'Removing worker'
20
20
  Process.kill :KILL, pid
21
- rescue StandardError => error
22
- log_warn "Ignoring error killing worker #{self}, error: #{error}"
21
+ rescue StandardError => e
22
+ log_warn "Ignoring error killing worker #{self}, error: #{e}"
23
23
  ensure
24
24
  close_parent_pipes
25
25
  close_child_pipes
@@ -16,8 +16,8 @@ module Fasten
16
16
  def kill
17
17
  log_info 'Removing worker'
18
18
  thread.exit
19
- rescue StandardError => error
20
- log_warn "Ignoring error killing worker #{self}, error: #{error}"
19
+ rescue StandardError => e
20
+ log_warn "Ignoring error killing worker #{self}, error: #{e}"
21
21
  ensure
22
22
  @queue.clear
23
23
  end
data/lib/fasten/task.rb CHANGED
@@ -5,15 +5,16 @@ module Fasten
5
5
  include Fasten::Support::State
6
6
 
7
7
  attr_accessor :name, :after, :shell, :ruby, :worker_class
8
- attr_accessor :dependants, :depends, :request, :response, :worker, :run_score, :block
8
+ attr_accessor :dependants, :depends, :request, :response, :worker, :run_score, :weight, :block
9
9
 
10
- def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, worker_class: nil)
10
+ def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, 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.weight = weight
17
18
  self.worker_class = worker_class
18
19
  end
19
20
 
@@ -1,5 +1,5 @@
1
1
  module Fasten
2
- class TaskManager < Array
2
+ class TaskManager < Array # rubocop:disable Metrics/ClassLength
3
3
  attr_reader :done, :failed, :pending, :running, :targets
4
4
 
5
5
  def initialize(targets: [])
@@ -13,7 +13,7 @@ module Fasten
13
13
  end
14
14
  end
15
15
 
16
- def receive_with_timeout(timeout = nil) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
16
+ def receive_with_timeout(timeout = nil) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
17
17
  @mutex.synchronize do
18
18
  if timeout.nil?
19
19
  # wait indefinitely until there is an element in the queue
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fasten
4
- VERSION = '0.10.0'
4
+ VERSION = '0.12.0'
5
5
  end
data/lib/fasten/worker.rb CHANGED
@@ -98,9 +98,9 @@ module Fasten
98
98
 
99
99
  perform(task)
100
100
  task.state = :DONE
101
- rescue StandardError => error
101
+ rescue StandardError => e
102
102
  task.state = :FAIL
103
- task.error = WorkerError.new(error)
103
+ task.error = WorkerError.new(e)
104
104
  ensure
105
105
  log_fin task, 'perform_task'
106
106
  send_response_to_parent(task)
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.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-04 00:00:00.000000000 Z
11
+ date: 2019-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler