sensu-extension 0.0.1 → 0.0.2
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 +4 -4
- data/lib/sensu/extension.rb +8 -9
- data/sensu-extension.gemspec +1 -1
- data/spec/base_spec.rb +17 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21c7b06cebe3494d4c2120d9197c0cfef8e8587b
|
4
|
+
data.tar.gz: e47c912539ab3b791791aa343be02deeb780a372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 032310825d74e68d6367ee9c71433d887bde7c95b543b642179f28318822a00d7986f06e7b651944bb7680e95adca18f2b2e84378e439c193d57abaf6fe9cc2c
|
7
|
+
data.tar.gz: 94c6f87fa29b2d612f95fb959dcddfe16cb1f86b64dad41e450067af51f213885c0689fc0c849a7bd26fea0dd778529bd74279455093aff62ca6d68aec70d572
|
data/lib/sensu/extension.rb
CHANGED
@@ -15,11 +15,14 @@ module Sensu
|
|
15
15
|
attr_accessor :settings
|
16
16
|
|
17
17
|
# Initialize the extension, call post_init() when the
|
18
|
-
# eventmachine reactor starts up.
|
18
|
+
# eventmachine reactor starts up, stop() when it stops.
|
19
19
|
def initialize
|
20
20
|
EM.next_tick do
|
21
21
|
post_init
|
22
22
|
end
|
23
|
+
EM.add_shutdown_hook do
|
24
|
+
stop
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
# Override this method to set the extension's name.
|
@@ -60,14 +63,10 @@ module Sensu
|
|
60
63
|
callback.call("noop", 0)
|
61
64
|
end
|
62
65
|
|
63
|
-
# Override this method to do something
|
64
|
-
# as connection or file cleanup.
|
65
|
-
|
66
|
-
|
67
|
-
# @param callback [Proc] provided by Sensu, expecting to be
|
68
|
-
# called.
|
69
|
-
def stop(&callback)
|
70
|
-
callback.call
|
66
|
+
# Override this method to do something when the eventmachine
|
67
|
+
# reactor stops, such as connection or file cleanup.
|
68
|
+
def stop
|
69
|
+
true
|
71
70
|
end
|
72
71
|
|
73
72
|
# Retrieve the definition object corresponding to a key, acting
|
data/sensu-extension.gemspec
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -10,11 +10,12 @@ describe "Sensu::Extension::Base" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "can provide the extension API" do
|
13
|
-
@extension.should respond_to(:name, :description, :definition, :safe_run, :
|
13
|
+
@extension.should respond_to(:name, :description, :definition, :safe_run, :has_key?, :[])
|
14
14
|
end
|
15
15
|
|
16
16
|
it "can provide default method return values" do
|
17
17
|
@extension.post_init.should be_true
|
18
|
+
@extension.stop.should be_true
|
18
19
|
@extension.name.should eq("base")
|
19
20
|
@extension.description.should eq("extension description (change me)")
|
20
21
|
@extension.definition.should eq({:type => "extension", :name => "base"})
|
@@ -35,20 +36,30 @@ describe "Sensu::Extension::Base" do
|
|
35
36
|
@extension.settings.should eq(settings)
|
36
37
|
end
|
37
38
|
|
38
|
-
it "can
|
39
|
+
it "can run without data" do
|
39
40
|
async_wrapper do
|
40
41
|
callback = Proc.new do |output, status|
|
41
42
|
output.should eq("noop")
|
42
43
|
status.should eq(0)
|
43
|
-
|
44
|
-
async_done
|
45
|
-
end
|
44
|
+
async_done
|
46
45
|
end
|
47
46
|
@extension.run(&callback)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
it "can
|
50
|
+
it "can run with event data" do
|
51
|
+
async_wrapper do
|
52
|
+
callback = Proc.new do |output, status|
|
53
|
+
output.should eq("noop")
|
54
|
+
status.should eq(0)
|
55
|
+
async_done
|
56
|
+
end
|
57
|
+
event = {:foo => 1}
|
58
|
+
@extension.run(event, &callback)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can pass duplicated event data to run" do
|
52
63
|
async_wrapper do
|
53
64
|
event = {:foo => 1}
|
54
65
|
@extension.safe_run(event) do |output, status|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-em
|