routemaster-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-client (0.0.1)
4
+ routemaster-client (0.0.2)
5
5
  faraday
6
6
  net-http-persistent
7
7
  sinatra
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  class Client
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -48,7 +48,7 @@ module Routemaster
48
48
  _assert_valid_url(options[:callback])
49
49
 
50
50
  data = options.to_json
51
- response = _conn.post('/subscription') do |r|
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 = _conn.post("/topics/#{topic}") do |r|
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.timeout = @_timeout
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.1
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-16 00:00:00.000000000 Z
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: 4434098965730026885
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: 4434098965730026885
226
+ hash: -3992781914019292519
227
227
  requirements: []
228
228
  rubyforge_project:
229
229
  rubygems_version: 1.8.23.2