riemann-client 0.2.1 → 0.2.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.
- data/README.markdown +2 -2
- data/lib/riemann.rb +1 -0
- data/lib/riemann/client.rb +3 -1
- data/lib/riemann/client/tcp.rb +8 -2
- data/lib/riemann/client/udp.rb +1 -1
- data/lib/riemann/version.rb +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -9,8 +9,8 @@ Use
|
|
9
9
|
``` ruby
|
10
10
|
require 'riemann/client'
|
11
11
|
|
12
|
-
# Create a client. Host and
|
13
|
-
c = Riemann::Client.new host: 'localhost', port: 5555
|
12
|
+
# Create a client. Host, port and timeout are optional.
|
13
|
+
c = Riemann::Client.new host: 'localhost', port: 5555, timeout: 5
|
14
14
|
|
15
15
|
# Send a simple event
|
16
16
|
c << {service: 'testing', metric: 2.5}
|
data/lib/riemann.rb
CHANGED
data/lib/riemann/client.rb
CHANGED
@@ -13,15 +13,17 @@ class Riemann::Client
|
|
13
13
|
|
14
14
|
HOST = '127.0.0.1'
|
15
15
|
PORT = 5555
|
16
|
+
TIMEOUT = 5
|
16
17
|
|
17
18
|
require 'riemann/client/tcp'
|
18
19
|
require 'riemann/client/udp'
|
19
20
|
|
20
|
-
attr_accessor :host, :port, :tcp, :udp
|
21
|
+
attr_accessor :host, :port, :tcp, :udp, :timeout
|
21
22
|
|
22
23
|
def initialize(opts = {})
|
23
24
|
@host = opts[:host] || HOST
|
24
25
|
@port = opts[:port] || PORT
|
26
|
+
@timeout = opts[:timeout] || TIMEOUT
|
25
27
|
@udp = UDP.new opts
|
26
28
|
@tcp = TCP.new opts
|
27
29
|
end
|
data/lib/riemann/client/tcp.rb
CHANGED
@@ -6,11 +6,14 @@ module Riemann
|
|
6
6
|
def initialize(opts = {})
|
7
7
|
@host = opts[:host] || HOST
|
8
8
|
@port = opts[:port] || PORT
|
9
|
+
@timeout = opts[:timeout] || TIMEOUT
|
9
10
|
@locket = Mutex.new
|
10
11
|
end
|
11
12
|
|
12
13
|
def connect
|
13
|
-
|
14
|
+
Timeout::timeout(@timeout) do
|
15
|
+
@socket = TCPSocket.new(@host, @port)
|
16
|
+
end
|
14
17
|
end
|
15
18
|
|
16
19
|
def close
|
@@ -20,7 +23,7 @@ module Riemann
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def connected?
|
23
|
-
|
26
|
+
!@socket && @socket.closed?
|
24
27
|
end
|
25
28
|
|
26
29
|
# Read a message from a stream
|
@@ -78,6 +81,9 @@ module Riemann
|
|
78
81
|
rescue InvalidResponse => e
|
79
82
|
raise if tries > 3
|
80
83
|
connect and retry
|
84
|
+
rescue Timeout::Error => e
|
85
|
+
raise if tries > 3
|
86
|
+
connect and retry
|
81
87
|
end
|
82
88
|
end
|
83
89
|
end
|
data/lib/riemann/client/udp.rb
CHANGED
data/lib/riemann/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beefcake
|