sidekiq-monitoring 0.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/sidekiq-monitoring.rb +11 -6
  4. metadata +9 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe841d0534ee44c3874a938fe210f0ebe2eb61ba
4
- data.tar.gz: 8921f0909260f88dea2875ca2a46dd327c5c4c84
3
+ metadata.gz: 2962983b286d3606392025686ba29449a381d3ef
4
+ data.tar.gz: 8203d683a721ef29dd21c83c95c29c06a2e18488
5
5
  SHA512:
6
- metadata.gz: 800b10be6050093c91a90d081e4ac1b66de180c360f5b4310088a80f0b36cd5edc9342767b073c811e88e35b2787aaff80f70cf021990fc55a2fe2ef21fb5ab0
7
- data.tar.gz: 86d7c72544cc46c118db18705a02456b9954ddcb7efac08ae77727f1a30afd575299e7d11b97f13f1cca346cd4677abef80e36532e155cfce6b899d8280fdd4b
6
+ metadata.gz: 8362d904815946e092c1322ca75a49de970f63ee6c3e7fcc7bbd5376fc463d50dc14bbaf52d3895977ab77ff136b3709d12869a096ca080d4b62162b3a1900d7
7
+ data.tar.gz: de7bb1025487da6e6ae44dda4179662b8ec9318cd66580ac24dbc5ce57e80cc25484d7bab805cb2763ac955e1e60368fdaaa74baf64774df1b02e0631c715339
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4
1
+ 0.5.1
@@ -3,11 +3,16 @@ require 'multi_json'
3
3
 
4
4
  class SidekiqMonitoring < Sinatra::Base
5
5
 
6
- cattr_accessor :thresholds
6
+ # Set yours down thresholds configuration
7
+ # {'default' => [ 1_000, 2_000 ], 'low' => [ 10_000, 20_000 ] }
8
+ def self.thresholds=(thresholds)
9
+ @@thresholds = thresholds
10
+ end
11
+ @@thresholds = {}
7
12
 
8
13
  get '/sidekiq_queues' do
9
14
  content_type :json
10
- MultiJson.dump SidekiqMonitoring::Global.new(thresholds)
15
+ MultiJson.dump SidekiqMonitoring::Global.new(@@thresholds)
11
16
  end
12
17
 
13
18
  class Queue
@@ -36,7 +41,7 @@ class SidekiqMonitoring < Sinatra::Base
36
41
  def initialize(name, size, thresholds = nil)
37
42
  @name = name
38
43
  @size = size
39
- @warning_threshold, @critical_threshold = (thresholds.present? ? thresholds : DEFAULT_THRESHOLD)
44
+ @warning_threshold, @critical_threshold = (thresholds ? thresholds : DEFAULT_THRESHOLD)
40
45
  @status = monitoring_status
41
46
  end
42
47
 
@@ -59,12 +64,12 @@ class SidekiqMonitoring < Sinatra::Base
59
64
  def as_json(options = {})
60
65
  {
61
66
  'global_status' => global_status,
62
- 'queues' => queues.as_json
67
+ 'queues' => queues.map(&:as_json)
63
68
  }
64
69
  end
65
70
 
66
71
  def global_status
67
- @global_status ||= queues.sort.last.try(:status) || 'UNKNOWN'
72
+ @global_status ||= (queues.sort.last && queues.sort.last.status) || 'UNKNOWN'
68
73
  end
69
74
 
70
75
  def initialize(thresholds = {})
@@ -78,7 +83,7 @@ class SidekiqMonitoring < Sinatra::Base
78
83
  end
79
84
 
80
85
  def thresholds_from_queue(queue_name)
81
- thresholds.fetch(queue_name) { |threshold| threshold['default'] }
86
+ (thresholds || {}).fetch(queue_name) { |threshold| threshold['default'] }
82
87
  end
83
88
 
84
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Carlier
8
8
  autorequire:
9
9
  bindir: ''
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: activesupport
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: activemodel
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: rack-test
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -84,30 +56,30 @@ dependencies:
84
56
  name: rspec
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
- - - ">="
59
+ - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '0'
61
+ version: '2'
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
- - - ">="
66
+ - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '0'
68
+ version: '2'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: sidekiq
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: 3.1.0
75
+ version: '3.1'
104
76
  type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
- version: 3.1.0
82
+ version: '3.1'
111
83
  description: Give a state of sidekiq available queues
112
84
  email: jeremy.carlier@dimelo.com
113
85
  executables: []
@@ -136,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
108
  version: '0'
137
109
  requirements: []
138
110
  rubyforge_project:
139
- rubygems_version: 2.2.2
111
+ rubygems_version: 2.4.1
140
112
  signing_key:
141
113
  specification_version: 4
142
114
  summary: Addons to provide a monitoring API for Sidekiq