routemaster-client 0.0.1 → 0.0.2
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.
- data/Gemfile.lock +1 -1
- data/routemaster/client/version.rb +1 -1
- data/routemaster/client.rb +14 -3
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/routemaster/client.rb
CHANGED
@@ -48,7 +48,7 @@ module Routemaster
|
|
48
48
|
_assert_valid_url(options[:callback])
|
49
49
|
|
50
50
|
data = options.to_json
|
51
|
-
response =
|
51
|
+
response = _post('/subscription') do |r|
|
52
52
|
r.headers['Content-Type'] = 'application/json'
|
53
53
|
r.body = data
|
54
54
|
end
|
@@ -83,7 +83,7 @@ module Routemaster
|
|
83
83
|
_assert_valid_url(callback)
|
84
84
|
_assert_valid_topic(topic)
|
85
85
|
data = { type: event, url: callback }.to_json
|
86
|
-
response =
|
86
|
+
response = _post("/topics/#{topic}") do |r|
|
87
87
|
r.headers['Content-Type'] = 'application/json'
|
88
88
|
r.body = data
|
89
89
|
end
|
@@ -94,11 +94,22 @@ module Routemaster
|
|
94
94
|
condition or raise ArgumentError.new(message)
|
95
95
|
end
|
96
96
|
|
97
|
+
def _post(path, &block)
|
98
|
+
retries ||= 5
|
99
|
+
_conn.post(path, &block)
|
100
|
+
rescue Net::HTTP::Persistent::Error => e
|
101
|
+
raise if (retries -= 1).zero?
|
102
|
+
puts "warning: retrying post to #{path} on #{e.class.name}: #{e.message} (#{retries})"
|
103
|
+
@_conn = nil
|
104
|
+
retry
|
105
|
+
end
|
106
|
+
|
107
|
+
|
97
108
|
def _conn
|
98
109
|
@_conn ||= Faraday.new(@_url) do |f|
|
99
110
|
f.use Faraday::Request::BasicAuthentication, @_uuid, 'x'
|
100
111
|
f.adapter :net_http_persistent
|
101
|
-
f.options
|
112
|
+
f.options[:timeout] = @_timeout
|
102
113
|
end
|
103
114
|
end
|
104
115
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routemaster-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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: 2014-07-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: -3992781914019292519
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
none: false
|
220
220
|
requirements:
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
segments:
|
225
225
|
- 0
|
226
|
-
hash:
|
226
|
+
hash: -3992781914019292519
|
227
227
|
requirements: []
|
228
228
|
rubyforge_project:
|
229
229
|
rubygems_version: 1.8.23.2
|