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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ca6b15c3e2131c39c0ebee88a04cda7dd4995dc
4
- data.tar.gz: c7e5f47fc0fcf7f16e345847178288133188df6b
3
+ metadata.gz: 8d03b673ba89014ffbe0bb86c4455350c51aaba5
4
+ data.tar.gz: 0b257ccfefc1ccb43fd8a1ce76c51e962f55a6a7
5
5
  SHA512:
6
- metadata.gz: e15fe6ed1788991886a59eef139c100d6cc36c161384241a90b049715cf55d95aa315afdf493c9bb48ceeaa518f491174d0ae76c0cce1915e61634b6b54c1d22
7
- data.tar.gz: b8d341c9549391e8e8a1af4a045444a0c84f6e82dd47fa161c892e2b636431ff059c49f21c2cb0b3a3d8fb31790d45683567561b10867929575397603777d114
6
+ metadata.gz: 9441471eb45d0dda1cb34d9c562534295ecb96cc0f2fcd5e8fcabfd75c52666f7818f6aeaae07476f6af2026159174015eb75667e0e4341a4bf98dd9e98f68b9
7
+ data.tar.gz: f00e42c5824473da725b9ec89787982f9fe3055bab4512abab23b3bf047501c6c4a21e36ca1231dacec66f4094fdb4a981ba1643566b34d2cf7419b759623b2f
@@ -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]) { send_metrics } unless options[:direct]
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
@@ -1,3 +1,3 @@
1
1
  module GraphiteAPI
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
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.2
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: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine