sensu-transport 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +2 -1
- data/lib/sensu/transport/base.rb +0 -11
- data/lib/sensu/transport.rb +21 -6
- data/sensu-transport.gemspec +1 -1
- data/spec/base_spec.rb +0 -1
- data/spec/helpers.rb +2 -2
- data/spec/rabbitmq_spec.rb +0 -1
- data/spec/transport_spec.rb +12 -0
- 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: 2cdc17cbd6f9e0e4fd7725b6942e8ed1690dba37
|
4
|
+
data.tar.gz: 93154f4c346571558290cb68891c414a24524381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04780b034644b8f23e5acd80c5a0a7df10bd247cecf39729d28ec20c968b931d73dc334eed69c6295054778a83d75e9471fdb52ece4b987dfe90b50ad51b5827
|
7
|
+
data.tar.gz: 92f1e633b476f33bc97e3bc2eeb6726cd3659d8c7790049c2a1b3eb3bd15006fd5169f398844c84017dba9ec4b077e8b84f0d4ed804f6b781e051c5ba84e6080
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/sensu/transport/base.rb
CHANGED
@@ -57,17 +57,6 @@ module Sensu
|
|
57
57
|
# Close the transport connection.
|
58
58
|
def close; end
|
59
59
|
|
60
|
-
# Connects to the transport.
|
61
|
-
#
|
62
|
-
# @param options [Hash, String]
|
63
|
-
# @return [Transport] the transport object.
|
64
|
-
def self.connect(options={})
|
65
|
-
options ||= {}
|
66
|
-
transport = self.new
|
67
|
-
transport.connect(options)
|
68
|
-
transport
|
69
|
-
end
|
70
|
-
|
71
60
|
# Publish a message to the transport.
|
72
61
|
#
|
73
62
|
# @param type [Symbol] the transport pipe type, possible values
|
data/lib/sensu/transport.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
module Sensu
|
2
2
|
module Transport
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class << self
|
4
|
+
# Set the transport logger.
|
5
|
+
#
|
6
|
+
# @param logger [Object] transport logger.
|
7
|
+
def logger=(logger)
|
8
|
+
@logger = logger
|
9
|
+
end
|
10
|
+
|
11
|
+
# Connect to a transport.
|
12
|
+
#
|
13
|
+
# @param transport_name [String] transport name.
|
14
|
+
# @param options [Hash] transport options.
|
15
|
+
def connect(transport_name, options={})
|
16
|
+
require("sensu/transport/#{transport_name}")
|
17
|
+
klass = Base.descendants.detect do |klass|
|
18
|
+
klass.name.downcase.split("::").last == transport_name
|
19
|
+
end
|
20
|
+
transport = klass.new
|
21
|
+
transport.logger = @logger
|
22
|
+
transport.connect(options)
|
23
|
+
transport
|
7
24
|
end
|
8
|
-
object = klass.connect(options)
|
9
|
-
object
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
data/sensu-transport.gemspec
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -9,7 +9,6 @@ describe "Sensu::Transport::Base" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "provides a transport API (noop)" do
|
12
|
-
Sensu::Transport::Base.should respond_to(:connect)
|
13
12
|
@transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
|
14
13
|
:connect, :connected?, :close,
|
15
14
|
:publish, :subscribe, :unsubscribe,
|
data/spec/helpers.rb
CHANGED
@@ -15,7 +15,7 @@ module Helpers
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def async_wrapper(&callback)
|
18
|
-
EM
|
18
|
+
EM.run do
|
19
19
|
timer(10) do
|
20
20
|
raise "test timed out"
|
21
21
|
end
|
@@ -24,6 +24,6 @@ module Helpers
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def async_done
|
27
|
-
EM
|
27
|
+
EM.stop_event_loop
|
28
28
|
end
|
29
29
|
end
|
data/spec/rabbitmq_spec.rb
CHANGED
@@ -12,7 +12,6 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "provides a transport API" do
|
15
|
-
Sensu::Transport::RabbitMQ.should respond_to(:connect)
|
16
15
|
@transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
|
17
16
|
:connect, :connected?, :close,
|
18
17
|
:publish, :subscribe, :unsubscribe,
|
data/spec/transport_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "helpers")
|
2
2
|
require "sensu/transport"
|
3
|
+
require "logger"
|
3
4
|
|
4
5
|
describe "Sensu::Transport" do
|
5
6
|
include Helpers
|
@@ -14,4 +15,15 @@ describe "Sensu::Transport" do
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
19
|
+
it "can set the transport logger" do
|
20
|
+
async_wrapper do
|
21
|
+
logger = Logger.new(STDOUT)
|
22
|
+
Sensu::Transport.logger = logger
|
23
|
+
transport = Sensu::Transport.connect("rabbitmq")
|
24
|
+
transport.logger.should eq(logger)
|
25
|
+
transport.logger.should respond_to(:error)
|
26
|
+
async_done
|
27
|
+
end
|
28
|
+
end
|
17
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-em
|