sidekiq-nag 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.md +5 -0
- data/lib/sidekiq-nag.rb +2 -0
- data/lib/sidekiq-nag/config.rb +13 -3
- data/lib/sidekiq-nag/notifier.rb +3 -6
- data/lib/sidekiq-nag/notifiers/campfire.rb +21 -0
- data/lib/sidekiq-nag/notifiers/hipchat.rb +22 -0
- data/lib/sidekiq-nag/version.rb +1 -1
- data/sidekiq-nag.gemspec +1 -0
- metadata +26 -7
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,11 @@ Add a `sidekiq-nag.yml` file to the `config/` directory that looks like this:
|
|
33
33
|
token: NoaTOEX23...
|
34
34
|
subdomain: foo3
|
35
35
|
room: TheZone
|
36
|
+
# or
|
37
|
+
|
38
|
+
hipchat:
|
39
|
+
token: NoaT0EX23....
|
40
|
+
room: TheZone
|
36
41
|
|
37
42
|
The timeout entered next to each queue name is specified in minutes.
|
38
43
|
|
data/lib/sidekiq-nag.rb
CHANGED
data/lib/sidekiq-nag/config.rb
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
module Sidekiq::Nag
|
2
2
|
class Config
|
3
|
-
attr_reader :queues, :campfire
|
3
|
+
attr_reader :queues, :campfire, :hipchat
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@queues = raw_yaml['queues']
|
7
7
|
@campfire = raw_yaml['campfire']
|
8
|
+
@hipchat = raw_yaml['hipchat']
|
8
9
|
end
|
9
10
|
|
10
11
|
def room
|
11
|
-
|
12
|
+
notifier['room']
|
12
13
|
end
|
13
14
|
|
14
15
|
def token
|
15
|
-
|
16
|
+
notifier['token']
|
16
17
|
end
|
17
18
|
|
18
19
|
def subdomain
|
19
20
|
campfire['subdomain']
|
20
21
|
end
|
21
22
|
|
23
|
+
def uses_campfire?
|
24
|
+
raw_yaml.has_key?('campfire')
|
25
|
+
end
|
26
|
+
|
22
27
|
private
|
28
|
+
def notifier
|
29
|
+
uses_campfire? ? campfire : hipchat
|
30
|
+
end
|
31
|
+
|
32
|
+
|
23
33
|
def raw_yaml
|
24
34
|
@raw_yaml ||= YAML::load_file(Rails.root + 'config/sidekiq-nag.yml')
|
25
35
|
end
|
data/lib/sidekiq-nag/notifier.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
class Sidekiq::Nag::Notifier
|
2
|
-
|
2
|
+
attr_reader :notifier
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
|
6
|
-
@room = campfire.find_room_by_name(config.room)
|
5
|
+
@notifier = config.uses_campfire? ? Sidekiq::Nag::Notifiers::Campfire.new : Sidekiq::Nag::Notifiers::Hipchat.new
|
7
6
|
end
|
8
7
|
|
9
8
|
def nag_about_queue(queue, timeout)
|
10
|
-
|
9
|
+
notifier.nag_about_queue(queue, timeout)
|
11
10
|
end
|
12
11
|
|
13
12
|
private
|
14
|
-
attr_reader :room
|
15
|
-
|
16
13
|
def config
|
17
14
|
@config ||= Sidekiq::Nag::Config.new
|
18
15
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sidekiq::Nag::Notifiers
|
2
|
+
class Campfire
|
3
|
+
require 'tinder'
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
campfire = Tinder::Campfire.new(config.subdomain, :token => config.token)
|
7
|
+
@room = campfire.find_room_by_name(config.room)
|
8
|
+
end
|
9
|
+
|
10
|
+
def nag_about_queue(queue, timeout)
|
11
|
+
room.speak(":no_good: excuse me, the '#{queue}' queue has been chilling for at least #{timeout} minutes...")
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
attr_reader :room
|
16
|
+
|
17
|
+
def config
|
18
|
+
@config ||= Sidekiq::Nag::Config.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sidekiq::Nag::Notifiers
|
2
|
+
class Hipchat
|
3
|
+
require 'hipchat-api'
|
4
|
+
|
5
|
+
attr_reader :hipchat_api
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@hipchat_api = HipChat::API.new(config.token)
|
9
|
+
@room_name = config.room
|
10
|
+
end
|
11
|
+
|
12
|
+
def nag_about_queue(queue, timeout)
|
13
|
+
message = "excuse me, the '#{queue}' queue has been chilling for at least #{timeout} minutes..."
|
14
|
+
@hipchat_api.rooms_message(@room_name, 'Sidekiq-nag', message, notify = 0, colour = 'red', message_format = 'text')
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def config
|
19
|
+
@config ||= Sidekiq::Nag::Config.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/sidekiq-nag/version.rb
CHANGED
data/sidekiq-nag.gemspec
CHANGED
metadata
CHANGED
@@ -1,32 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-nag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Gary Greyling
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
15
|
+
name: tinder
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
|
-
none: false
|
21
|
-
name: tinder
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hipchat-api
|
24
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
25
34
|
requirements:
|
26
35
|
- - ! '>='
|
27
36
|
- !ruby/object:Gem::Version
|
28
37
|
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
41
|
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: A Sidekiq extension that will notify you of queues that take too long
|
31
47
|
to process
|
32
48
|
email:
|
@@ -46,6 +62,8 @@ files:
|
|
46
62
|
- lib/sidekiq-nag/middleware/timestamper.rb
|
47
63
|
- lib/sidekiq-nag/nagger.rb
|
48
64
|
- lib/sidekiq-nag/notifier.rb
|
65
|
+
- lib/sidekiq-nag/notifiers/campfire.rb
|
66
|
+
- lib/sidekiq-nag/notifiers/hipchat.rb
|
49
67
|
- lib/sidekiq-nag/railtie.rb
|
50
68
|
- lib/sidekiq-nag/version.rb
|
51
69
|
- lib/tasks/nag.rake
|
@@ -57,17 +75,17 @@ rdoc_options: []
|
|
57
75
|
require_paths:
|
58
76
|
- lib
|
59
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
60
79
|
requirements:
|
61
80
|
- - ! '>='
|
62
81
|
- !ruby/object:Gem::Version
|
63
82
|
version: '0'
|
64
|
-
none: false
|
65
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
66
85
|
requirements:
|
67
86
|
- - ! '>='
|
68
87
|
- !ruby/object:Gem::Version
|
69
88
|
version: '0'
|
70
|
-
none: false
|
71
89
|
requirements: []
|
72
90
|
rubyforge_project:
|
73
91
|
rubygems_version: 1.8.23
|
@@ -75,3 +93,4 @@ signing_key:
|
|
75
93
|
specification_version: 3
|
76
94
|
summary: Campfire notification of stationary Sidekiq queues
|
77
95
|
test_files: []
|
96
|
+
has_rdoc:
|