protor 0.0.5 → 0.0.6
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/protor/client.rb +32 -12
- data/lib/protor/configuration.rb +7 -1
- data/lib/protor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff72000d5fb00510aa40d7f08df563673744c9d7
|
4
|
+
data.tar.gz: e59aa78f2b2c9b089cba768a4af71d5aafe22109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce72db467c7c6b848a5d247a9f83bed21ec53bcb33262f6e54a9daab6a9c5ae38e9f0a739b89fdc57a829bae304948dac21ece0df1bc2c6b187a9a9b96eda133
|
7
|
+
data.tar.gz: c78d3d8ec843cf4a8865498bb56a8167e86df98b9838e71276431abc78ccadfbcd4059161205f891780ea1a8fe13bc55423688059e5d55cd70304f311c9c42e3
|
data/lib/protor/client.rb
CHANGED
@@ -4,27 +4,47 @@ module Protor
|
|
4
4
|
class Client
|
5
5
|
def initialize(configuration)
|
6
6
|
@options = configuration
|
7
|
+
@retries = 0
|
7
8
|
end
|
8
9
|
|
9
10
|
def publish(payload)
|
10
|
-
|
11
|
-
|
11
|
+
connect
|
12
|
+
payload.each do |message|
|
13
|
+
send(message)
|
12
14
|
end
|
15
|
+
rescue Errno::EPERM, Errno::ECONNREFUSED => e
|
16
|
+
options.logger.error(e)
|
17
|
+
ensure
|
18
|
+
close
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
16
22
|
|
17
|
-
attr_reader :options
|
23
|
+
attr_reader :options, :connection, :retries
|
18
24
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def send(message)
|
26
|
+
connection.send(message, 0)
|
27
|
+
rescue Errno::EPERM => exception
|
28
|
+
retries += 1
|
29
|
+
if retries <= 3
|
30
|
+
refresh && retry
|
31
|
+
else
|
32
|
+
raise exception
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def connect
|
37
|
+
@connection = UDPSocket.new
|
38
|
+
@connection.connect(options.host, options.port)
|
39
|
+
end
|
40
|
+
|
41
|
+
def refresh
|
42
|
+
close
|
43
|
+
connect
|
44
|
+
end
|
45
|
+
|
46
|
+
def close
|
47
|
+
connection.close unless connection.closed?
|
28
48
|
end
|
29
49
|
end
|
30
50
|
end
|
data/lib/protor/configuration.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
1
3
|
module Protor
|
2
4
|
class Configuration
|
3
|
-
attr_writer :host, :port, :max_packet_size
|
5
|
+
attr_writer :host, :port, :max_packet_size, :logger
|
4
6
|
|
5
7
|
def host
|
6
8
|
@host ||= 'localhost'
|
@@ -13,5 +15,9 @@ module Protor
|
|
13
15
|
def max_packet_size
|
14
16
|
@max_packet_size ||= 56_607
|
15
17
|
end
|
18
|
+
|
19
|
+
def logger
|
20
|
+
@logger ||= Logger.new(STDOUT)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
data/lib/protor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roland Rinfandi Utama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -51,3 +51,4 @@ signing_key:
|
|
51
51
|
specification_version: 4
|
52
52
|
summary: Prometheus aggregator client for ruby.
|
53
53
|
test_files: []
|
54
|
+
has_rdoc:
|