esa 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/esa/client.rb +24 -3
- data/lib/esa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e539e9e9dd98be681d769ee35e195c2521953f88
|
4
|
+
data.tar.gz: 00565e222da28955c9a003da10cd3c1eb32ef437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a591ef1455f940ef94d2bfa2cb67bffe4fc9b746d12542b325cfd62fad072689e798a49f7449f4b0e0d081d9c8438b6ca12ca0a2c2cf14c5f067e3bcde9f6243
|
7
|
+
data.tar.gz: f1dd8a14cd8313c0c8e1bb89a6633cbcb35f7a7caddf4b98e34f3a6957d85a2f02ce0c7003408248de44e0203aaa94ed33030b8dc0bf60949ab8e255ca1ae088
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.13.0 (2017-11-01)
|
2
|
+
- **changed**: [Retry on rate limit exceeded by default](https://github.com/esaio/esa-ruby/pull/31)
|
3
|
+
- Use `Esa::Client.new(retry_on_rate_limit_exceeded: false, ...)` for previous behavior.
|
4
|
+
- doc: [Fixed README typo](https://github.com/esaio/esa-ruby/pull/30)
|
5
|
+
|
1
6
|
## 1.12.0 (2017-10-03)
|
2
7
|
- add: [Support /api/v1/comments API by ppworks · Pull Request #29 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/29)
|
3
8
|
|
data/README.md
CHANGED
data/lib/esa/client.rb
CHANGED
@@ -4,14 +4,18 @@ require "esa/response"
|
|
4
4
|
|
5
5
|
module Esa
|
6
6
|
class Client
|
7
|
+
class TooManyRequestError < StandardError; end
|
8
|
+
|
7
9
|
include ApiMethods
|
8
10
|
|
9
|
-
def initialize(access_token: nil, api_endpoint: nil, current_team: nil)
|
11
|
+
def initialize(access_token: nil, api_endpoint: nil, current_team: nil, retry_on_rate_limit_exceeded: true)
|
10
12
|
@access_token = access_token
|
11
13
|
@api_endpoint = api_endpoint
|
12
14
|
@current_team = current_team
|
15
|
+
|
16
|
+
@retry_on_rate_limit_exceeded = retry_on_rate_limit_exceeded
|
13
17
|
end
|
14
|
-
attr_accessor :current_team
|
18
|
+
attr_accessor :current_team, :retry_on_rate_limit_exceeded
|
15
19
|
|
16
20
|
def current_team!
|
17
21
|
raise TeamNotSpecifiedError, "current_team is not specified" unless @current_team
|
@@ -39,7 +43,14 @@ module Esa
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def send_request(method, path, params = nil, headers = nil)
|
42
|
-
|
46
|
+
response = esa_connection.send(method, path, params, headers)
|
47
|
+
raise TooManyRequestError if retry_on_rate_limit_exceeded && response.status == 429 # too_many_requests
|
48
|
+
Esa::Response.new(response)
|
49
|
+
rescue TooManyRequestError
|
50
|
+
wait_sec = response.headers['retry-after'].to_i
|
51
|
+
puts "Rate limit exceeded: will retry after #{wait_sec} seconds."
|
52
|
+
wait_for(wait_sec)
|
53
|
+
retry
|
43
54
|
end
|
44
55
|
|
45
56
|
def send_s3_request(method, path, params = nil, headers = nil)
|
@@ -101,5 +112,15 @@ module Esa
|
|
101
112
|
def faraday_url
|
102
113
|
@api_endpoint || ENV["ESA_API_ENDPOINT"] || "https://api.esa.io"
|
103
114
|
end
|
115
|
+
|
116
|
+
def wait_for(wait_sec)
|
117
|
+
return if wait_sec <= 0
|
118
|
+
|
119
|
+
(wait_sec / 10).times do
|
120
|
+
print '.'
|
121
|
+
sleep 10
|
122
|
+
end
|
123
|
+
puts
|
124
|
+
end
|
104
125
|
end
|
105
126
|
end
|
data/lib/esa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukayatsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|