graphite-api 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphite-api/client.rb +8 -5
- data/lib/graphite-api/version.rb +1 -1
- 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: 8d03b673ba89014ffbe0bb86c4455350c51aaba5
|
4
|
+
data.tar.gz: 0b257ccfefc1ccb43fd8a1ce76c51e962f55a6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9441471eb45d0dda1cb34d9c562534295ecb96cc0f2fcd5e8fcabfd75c52666f7818f6aeaae07476f6af2026159174015eb75667e0e4341a4bf98dd9e98f68b9
|
7
|
+
data.tar.gz: f00e42c5824473da725b9ec89787982f9fe3055bab4512abab23b3bf047501c6c4a21e36ca1231dacec66f4094fdb4a981ba1643566b34d2cf7419b759623b2f
|
data/lib/graphite-api/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require 'thread'
|
2
3
|
|
3
4
|
module GraphiteAPI
|
4
5
|
class Client
|
@@ -7,14 +8,16 @@ module GraphiteAPI
|
|
7
8
|
def_delegator Zscheduler, :loop, :join
|
8
9
|
def_delegator Zscheduler, :stop
|
9
10
|
|
10
|
-
attr_reader :options, :buffer, :connectors
|
11
|
+
attr_reader :options, :buffer, :connectors, :mu
|
12
|
+
private :options, :buffer, :connectors, :mu
|
11
13
|
|
12
14
|
def initialize opt
|
13
15
|
@options = build_options validate opt.clone
|
14
16
|
@buffer = GraphiteAPI::Buffer.new options
|
15
17
|
@connectors = GraphiteAPI::Connector::Group.new options
|
18
|
+
@mu = Mutex.new
|
16
19
|
|
17
|
-
Zscheduler.every(options[:interval])
|
20
|
+
Zscheduler.every(options[:interval],&method(:send_metrics!)) unless options[:direct]
|
18
21
|
end
|
19
22
|
|
20
23
|
# throw exception on Socket error
|
@@ -29,7 +32,7 @@ module GraphiteAPI
|
|
29
32
|
def metrics metric, time = Time.now
|
30
33
|
return if metric.empty?
|
31
34
|
buffer.push :metric => metric, :time => time
|
32
|
-
send_metrics if options[:direct]
|
35
|
+
send_metrics! if options[:direct]
|
33
36
|
end
|
34
37
|
|
35
38
|
def increment(*keys)
|
@@ -77,8 +80,8 @@ module GraphiteAPI
|
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
80
|
-
def send_metrics
|
81
|
-
connectors.publish buffer.pull :string if buffer.new_records?
|
83
|
+
def send_metrics!
|
84
|
+
mu.synchronize { connectors.publish buffer.pull :string if buffer.new_records? }
|
82
85
|
end
|
83
86
|
|
84
87
|
end
|
data/lib/graphite-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphite-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran Barak Levi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|