seatsio 31.0.0 → 32.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf1124000be835fc50c85b57259d3cc53d0efbb3625bff185329e412f0fd9b33
4
- data.tar.gz: 4f85fb99913ddb488705092c483c88ada2da298a0f9b7dbcee90df3cae558a4d
3
+ metadata.gz: 2a4c05feef8448daa977bdc2148b893bd92986ba8da80765f23b5dc80ac57f9e
4
+ data.tar.gz: aa0229bf2f040f406ac18b788b74fa540a16420de533cdecbe8ed1aec5abdf26
5
5
  SHA512:
6
- metadata.gz: fd5ed35d871c54d7101e78eaacb2fd9925ef0894e69d56150eecd671b04b8a01cafaabe57b51b94c02326c4a9acbdfe27fe1dbed1a680e3700c6d80ebef5723e
7
- data.tar.gz: 933fe7bb11ebcc7e9c15f8efbe8dafbfb5c9b584f351f5cef9c949a51a0dd243eda159077d8be2b79b042e9eaab44947b1c1b1feaabddb8ca554bc487e11e3b9
6
+ metadata.gz: 8f6d5d72e8e7defd3f34b8bbb042e60440047a0e705d62b6f71053cd8f59eacc34bdc62f1bf55c56cd44433ba621fa053eff782382bceb8978c8446140f0f23a
7
+ data.tar.gz: 2ff422ca32191907b0c22659ad8f6a295f74e4843c2bc3c96be27c2a208486e36ad410696159f27c3665fffc64307ba20e9e64e024b2fc0c46abbfb59d499ddc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seatsio (31.0.0)
4
+ seatsio (32.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -113,3 +113,11 @@ This exception contains a message string describing what went wrong, and also tw
113
113
 
114
114
  * *errors*: a list of errors that the server returned. In most cases, this array will contain only one element, an instance of ApiError, containing an error code and a message.
115
115
  * *requestId*: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.
116
+
117
+
118
+ ## Rate limiting - exponential backoff
119
+
120
+ This library supports [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff).
121
+
122
+ When you send too many concurrent requests, the server returns an error `429 - Too Many Requests`. We react to this by waiting for a while, and then retrying the request.
123
+ If the request still fails with an error `429`, we wait a little longer, and try again. This happens at most 5 times, before we give up (after approximately 15 seconds).
@@ -14,27 +14,24 @@ module Seatsio
14
14
 
15
15
  def execute(*args)
16
16
  begin
17
- headers = {:Authorization => "Basic #{@secret_key}"}
17
+ headers = { :Authorization => "Basic #{@secret_key}" }
18
18
  unless @workspace_key.nil?
19
19
  headers[:'X-Workspace-Key'] = @workspace_key
20
20
  end
21
21
  if args[2].include? :params
22
22
  headers[:params] = args[2][:params]
23
23
  end
24
- #if args[2] != nil || args[0] == :post
25
- # headers[:params] = args[2]
26
- #end
27
24
 
28
25
  url = "#{@base_url}/#{args[1]}"
29
26
 
30
- request_options = {method: args[0], url: url, headers: headers}
27
+ request_options = { method: args[0], url: url, headers: headers }
31
28
 
32
29
  if args[0] == :post
33
30
  args[2].delete :params
34
31
  request_options[:payload] = args[2].to_json
35
32
  end
36
33
 
37
- response = RestClient::Request.execute(request_options)
34
+ response = execute_with_retries(request_options)
38
35
 
39
36
  # If RAW
40
37
  if args[3]
@@ -44,9 +41,6 @@ module Seatsio
44
41
  rescue RestClient::NotFound => e
45
42
  raise Exception::NotFoundException.new(e.response)
46
43
  rescue RestClient::ExceptionWithResponse => e
47
- if e.response.include? "there is no page after" || e.response.empty?
48
- raise Exception::NoMorePagesException
49
- end
50
44
  raise Exception::SeatsioException.new(e.response)
51
45
  rescue RestClient::Exceptions::Timeout
52
46
  raise Exception::SeatsioException.new("Timeout ERROR")
@@ -55,12 +49,29 @@ module Seatsio
55
49
  end
56
50
  end
57
51
 
52
+ def execute_with_retries(request_options)
53
+ retry_count = 0
54
+ while true
55
+ begin
56
+ return RestClient::Request.execute(request_options)
57
+ rescue RestClient::ExceptionWithResponse => e
58
+ if e.response.code != 429 || retry_count >= 5
59
+ raise e
60
+ else
61
+ wait_time = (2 ** (retry_count + 2)) / 10.0
62
+ sleep(wait_time)
63
+ retry_count += 1
64
+ end
65
+ end
66
+ end
67
+ end
68
+
58
69
  def get_raw(endpoint, params = {})
59
70
  execute(:get, endpoint, params, true)
60
71
  end
61
72
 
62
73
  def get(endpoint, params = {})
63
- payload = {:params => params}
74
+ payload = { :params => params }
64
75
  execute(:get, endpoint, payload)
65
76
  end
66
77
 
@@ -89,8 +89,6 @@ module Seatsio
89
89
 
90
90
  @collection += parsed_items
91
91
  set_query_param(:start_after_id, items.last['id']) unless last?
92
- rescue Seatsio::Exception::NoMorePagesException
93
- @last_response_empty = true
94
92
  end
95
93
  end
96
94
  end
@@ -1,3 +1,3 @@
1
1
  module Seatsio
2
- VERSION = "31.0.0"
2
+ VERSION = "32.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seatsio
3
3
  version: !ruby/object:Gem::Version
4
- version: 31.0.0
4
+ version: 32.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seats.io
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2021-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler