workerholic 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87411ccdd61f7ed0ed20ad2b3ab8117c149cacda
4
- data.tar.gz: 75c6c7460028896447e6b6fd9f0303e80c163f98
3
+ metadata.gz: 2c83d9577835bf37fe458f1eec211b3b3290beef
4
+ data.tar.gz: 2cb91be6cad32404d1652a0912075c472c420815
5
5
  SHA512:
6
- metadata.gz: cb4ee345839b8d8a504719c7c313babf783cfd5f9dbc28e209257c3eb043195100416a59e9aca8f51da939e8b5a5202bae35b5c25fb2f49a53dd3b0f275d57a8
7
- data.tar.gz: '0890890140a602ce9a38a7896915b8224460beb9a4c2e5e6931500c5fc99fb7940249279dd51fb860e65ec5a530a0f30910965b0b862f42e5463dda9f6a0c792'
6
+ metadata.gz: a6876d6abb09a6fc454233dcadcac636f8153f451300c9645be508018defa9b28384cff95abd2b6127c9d5a48d7da777832eedd9bb8e85da4fc9a38e59c830b0
7
+ data.tar.gz: ddf1db604ee58382c66a6221c56b49d853feac73aff35214e911e7526b2d1d5a72176ca2a2992acd80056fb730639aaa2eafeef53d846c5bee20a74915135fd3
data/app_test/run.rb CHANGED
@@ -90,6 +90,6 @@ module TestRunner
90
90
  end
91
91
  end
92
92
 
93
- TestRunner.non_blocking(200)
94
- TestRunner.blocking(50000)
95
- TestRunner.fibonacci_cruncher(100)
93
+ TestRunner.non_blocking(10000)
94
+ TestRunner.blocking(10000)
95
+ TestRunner.fibonacci_cruncher(10000)
data/lib/workerholic.rb CHANGED
@@ -42,8 +42,17 @@ module Workerholic
42
42
  @workers_count = num
43
43
  end
44
44
 
45
+ def self.redis_connections_count
46
+ @redis_connections_count || (workers_count + 5)
47
+ end
48
+
49
+ def self.redis_connections_count=(num)
50
+ raise ArgumentError unless num.is_a?(Integer) && num < 200
51
+ @redis_connections_count = num
52
+ end
53
+
45
54
  def self.redis_pool
46
- @redis ||= ConnectionPool.new(size: workers_count + 5, timeout: 5) do
55
+ @redis ||= ConnectionPool.new(size: redis_connections_count, timeout: 5) do
47
56
  Redis.new(url: REDIS_URL)
48
57
  end
49
58
  end
@@ -37,7 +37,7 @@ module Workerholic
37
37
  count = count.to_i
38
38
 
39
39
  if count < 1
40
- logger.error('Invalid number of workers. Please specify a valid number of workers.')
40
+ logger.error('Invalid number of workers. Please specify a valid number.')
41
41
  exit
42
42
  else
43
43
  options[:workers] = count.to_i
@@ -57,12 +57,23 @@ module Workerholic
57
57
  count = count.to_i
58
58
 
59
59
  if count < 1
60
- logger.error('Invalid number of processes. Please specify a valid number of processes.')
60
+ logger.error('Invalid number of processes. Please specify a valid number.')
61
61
  exit
62
62
  else
63
63
  options[:processes] = count.to_i
64
64
  end
65
65
  end
66
+
67
+ opts.on '-c', '--connections INT', 'number of connections for redis connection pool' do |count|
68
+ count = count.to_i
69
+
70
+ if count < 1
71
+ logger.error('Invalid number of redis connections. Please specify a valid number.')
72
+ exit
73
+ else
74
+ options[:redis_connections] = count.to_i
75
+ end
76
+ end
66
77
  end.parse!
67
78
  end
68
79
  end
@@ -28,6 +28,7 @@ module Workerholic
28
28
 
29
29
  def self.apply_options
30
30
  Workerholic.workers_count = options[:workers] if options[:workers]
31
+ Workerholic.redis_connections_count = options[:redis_connections] if options[:redis_connections]
31
32
  end
32
33
 
33
34
  def self.load_app
@@ -1,3 +1,3 @@
1
1
  module Workerholic
2
- VERSION = '0.0.20'
2
+ VERSION = '0.0.21'
3
3
  end
@@ -86,8 +86,16 @@ module Workerholic
86
86
  end
87
87
 
88
88
  def output_balancer_stats
89
- @logger.info(queues.map { |q| { name: q.name, size: q.size } })
90
- @logger.info(current_workers_count_per_queue)
89
+ queues_with_size = queues.map { |q| { name: q.name, size: q.size } }
90
+
91
+ queues_with_size.each do |q|
92
+ output = <<~LOG
93
+ Queue #{q[:name]}:
94
+ => #{q[:size]} jobs
95
+ => #{current_workers_count_per_queue[q[:name]]} workers
96
+ LOG
97
+ @logger.info(output)
98
+ end
91
99
  end
92
100
 
93
101
  def assign_one_worker_per_queue
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workerholic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Leclercq
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-05 00:00:00.000000000 Z
13
+ date: 2017-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redis