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.
- data/Gemfile.lock +1 -1
- data/History.md +4 -0
- data/Makefile +3 -0
- data/lib/analytics-ruby/defaults.rb +2 -0
- data/lib/analytics-ruby/request.rb +8 -2
- data/lib/analytics-ruby/version.rb +1 -1
- data/spec/consumer_spec.rb +8 -0
- metadata +2 -4
- data/analytics-ruby-0.4.0.gem +0 -0
- data/analytics-ruby-0.5.0.gem +0 -0
data/Gemfile.lock
CHANGED
data/History.md
CHANGED
data/Makefile
CHANGED
@@ -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 =
|
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
|
-
|
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
|
data/spec/consumer_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|
data/analytics-ruby-0.4.0.gem
DELETED
Binary file
|
data/analytics-ruby-0.5.0.gem
DELETED
Binary file
|