hirefire-resource 0.3.8 → 0.3.9

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
  SHA1:
3
- metadata.gz: 3a7d921ede6a7e56c74953e56112659b6ed54272
4
- data.tar.gz: 6a2466a4b097cd936732538678f6bbfe3252a3a8
3
+ metadata.gz: 55b749a5f42d84e6bab55c403be81132b083753f
4
+ data.tar.gz: 60e1543b6a620b45cc4dc25e38ca07c671db7695
5
5
  SHA512:
6
- metadata.gz: 1fd423e23b3ad9e5fdfd35c2c2fcce39b99cb833ffc75b0963e435c477777746ac54567717635c49f5c48602bc39b87fd757e1a07b711c65d5c6a2b1ade496d9
7
- data.tar.gz: eef43f3a9173ae8a910f3142ba6725a2b77a1a06192384140c56c24ad59c2c7c0a9bd6ca7116b0059d8f4a88cc546e12e82bce19fbc25f2d51a53c67adbcaed2
6
+ metadata.gz: 9e6009e98f7debbda254a5632e5111127bd0f7fa56b59414c024e2cf9ebe1437925a9af14c2e4634dec0aa0d85b6412bd2ffa3d9b3a36b0a4c594566c9ac4e32
7
+ data.tar.gz: b2cd03832e203d95728ef05055f074c3056758da9bfd8bac0d89dd5d623df7a15aa5682b3fa3ae797e849ab8f01c918018457b68526c19e44d565168ff9a3bd8
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "hirefire-resource"
5
- gem.version = "0.3.8"
5
+ gem.version = "0.3.9"
6
6
  gem.platform = Gem::Platform::RUBY
7
7
  gem.authors = "Michael van Rooijen"
8
8
  gem.email = "michael@hirefire.io"
@@ -11,6 +11,8 @@ module HireFire
11
11
  # HireFire::Macro::Sidekiq.queue # all queues
12
12
  # HireFire::Macro::Sidekiq.queue("email") # only email queue
13
13
  # HireFire::Macro::Sidekiq.queue("audio", "video") # audio and video queues
14
+ # HireFire::Macro::Sidekiq.queue("email", skip_scheduled: true) # only email, will not count scheduled queue
15
+ # HireFire::Macro::Sidekiq.queue("audio", skip_retries: true) # only audio, will not count the retries queue
14
16
  #
15
17
  # @param [Array] queues provide one or more queue names, or none for "all".
16
18
  # @return [Integer] the number of jobs in the queue(s).
@@ -18,7 +20,15 @@ module HireFire
18
20
  def queue(*queues)
19
21
  require "sidekiq/api"
20
22
 
21
- queues = queues.flatten.map(&:to_s)
23
+ queues.flatten!
24
+
25
+ if queues.last.is_a?(Hash)
26
+ options = queues.pop
27
+ else
28
+ options = {}
29
+ end
30
+
31
+ queues = queues.map(&:to_s)
22
32
  queues = ::Sidekiq::Stats.new.queues.map { |name, _| name } if queues.empty?
23
33
 
24
34
  in_queues = queues.inject(0) do |memo, name|
@@ -26,14 +36,18 @@ module HireFire
26
36
  memo
27
37
  end
28
38
 
29
- in_schedule = ::Sidekiq::ScheduledSet.new.inject(0) do |memo, job|
30
- memo += 1 if queues.include?(job["queue"]) && job.at <= Time.now
31
- memo
39
+ if !options[:skip_scheduled]
40
+ in_schedule = ::Sidekiq::ScheduledSet.new.inject(0) do |memo, job|
41
+ memo += 1 if queues.include?(job["queue"]) && job.at <= Time.now
42
+ memo
43
+ end
32
44
  end
33
45
 
34
- in_retry = ::Sidekiq::RetrySet.new.inject(0) do |memo, job|
35
- memo += 1 if queues.include?(job["queue"]) && job.at <= Time.now
36
- memo
46
+ if !options[:skip_retries]
47
+ in_retry = ::Sidekiq::RetrySet.new.inject(0) do |memo, job|
48
+ memo += 1 if queues.include?(job["queue"]) && job.at <= Time.now
49
+ memo
50
+ end
37
51
  end
38
52
 
39
53
  i = ::Sidekiq::VERSION >= "3.0.0" ? 2 : 1
@@ -42,7 +56,7 @@ module HireFire
42
56
  memo
43
57
  end
44
58
 
45
- in_queues + in_schedule + in_retry + in_progress
59
+ [in_queues, in_schedule, in_retry, in_progress].compact.inject(&:+)
46
60
  end
47
61
  end
48
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirefire-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-29 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Load-based scaling, schedule-based scaling, dyno crash recovery, for
14
14
  web- and worker dynos.
@@ -57,8 +57,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.4.5
60
+ rubygems_version: 2.4.5.1
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Autoscaling for your Heroku dynos
64
64
  test_files: []
65
+ has_rdoc: