analytics-ruby 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- analytics-ruby (0.5.0)
4
+ analytics-ruby (0.5.2)
5
5
  faraday (>= 0.8, < 0.10)
6
6
  faraday_middleware (>= 0.8, < 0.10)
7
7
  multi_json (~> 1.0)
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.2 / 2013-12-02
2
+ ==================
3
+ * adding `sleep` backoff between connection retries
4
+
1
5
  0.5.1 / 2013-11-22
2
6
  ==================
3
7
  * adding retries for connection hangups
data/Makefile CHANGED
@@ -2,4 +2,7 @@
2
2
  test:
3
3
  rake spec
4
4
 
5
+ build:
6
+ gem build ./analytics-ruby.gemspec
7
+
5
8
  .PHONY: test
@@ -7,6 +7,8 @@ module AnalyticsRuby
7
7
  PATH = '/v1/import' unless defined? AnalyticsRuby::Defaults::Request::PATH
8
8
  SSL = { :verify => false } unless defined? AnalyticsRuby::Defaults::Request::SSL
9
9
  HEADERS = { :accept => 'application/json' } unless defined? AnalyticsRuby::Defaults::Request::HEADERS
10
+ RETRIES = 4 unless defined? AnalyticsRuby::Defaults::Request::RETRIES
11
+ BACKOFF = 30.0 unless defined? AnalyticsRuby::Defaults::Request::BACKOFF
10
12
  end
11
13
 
12
14
  module Queue
@@ -17,6 +17,8 @@ module AnalyticsRuby
17
17
  options[:ssl] ||= AnalyticsRuby::Defaults::Request::SSL
18
18
  options[:headers] ||= AnalyticsRuby::Defaults::Request::HEADERS
19
19
  @path = options[:path] || AnalyticsRuby::Defaults::Request::PATH
20
+ @retries = options[:retries] || AnalyticsRuby::Defaults::Request::RETRIES
21
+ @backoff = options[:backoff] || AnalyticsRuby::Defaults::Request::BACKOFF
20
22
 
21
23
  @conn = Faraday.new options do |faraday|
22
24
  faraday.request :json
@@ -31,7 +33,8 @@ module AnalyticsRuby
31
33
  def post(secret, batch)
32
34
 
33
35
  status, error = nil, nil
34
- remaining_retries = 3
36
+ remaining_retries = @retries
37
+ backoff = @backoff
35
38
 
36
39
  begin
37
40
  res = @conn.post do |req|
@@ -46,7 +49,10 @@ module AnalyticsRuby
46
49
  rescue Exception => err
47
50
  status = -1
48
51
  error = "Connection error: #{err}"
49
- retry unless (remaining_retries -=1).zero?
52
+ unless (remaining_retries -=1).zero?
53
+ sleep(backoff)
54
+ retry
55
+ end
50
56
  end
51
57
 
52
58
  AnalyticsRuby::Response.new status, error
@@ -1,3 +1,3 @@
1
1
  module AnalyticsRuby
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -14,6 +14,14 @@ describe AnalyticsRuby::Consumer do
14
14
 
15
15
  describe '#flush' do
16
16
 
17
+ before :all do
18
+ AnalyticsRuby::Defaults::Request::BACKOFF = 0.1
19
+ end
20
+
21
+ after :all do
22
+ AnalyticsRuby::Defaults::Request::BACKOFF = 30.0
23
+ end
24
+
17
25
  it 'should not error if the endpoint is unreachable' do
18
26
 
19
27
  Faraday::Connection.any_instance.stub(:post).and_raise(Exception)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.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-11-22 00:00:00.000000000 Z
12
+ date: 2013-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -109,8 +109,6 @@ executables: []
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
- - analytics-ruby-0.4.0.gem
113
- - analytics-ruby-0.5.0.gem
114
112
  - analytics-ruby.gemspec
115
113
  - Gemfile
116
114
  - Gemfile.lock
Binary file
Binary file