seam 2.138.0 → 2.139.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/seam/http_single_workspace.rb +34 -2
- data/lib/seam/http_without_workspace.rb +37 -8
- data/lib/seam/request.rb +5 -1
- data/lib/seam/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b94008b86b31b1f480fc2c3276075bc61d83a74dd09ea0af2b7831f39e603c3
|
|
4
|
+
data.tar.gz: 1f4a039c2309d9b31c82cb9c295c09fb925161150f64eede25fcad60e35c89c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c23cbe8e1da6b13568c3cdb1676d7e19c68068aaa99b651ae1915ce4ec04eb776def06af72e3b592381e200e9dd85dbc20e7d568ebe60ea5092e17b27151b67c
|
|
7
|
+
data.tar.gz: 23f38b1e3c55349694570c17aa70a1d3e6696336d04ec0506ba4758360fdc2a651f9229263efb2c5168f95903f3525c85163ebb1b92de1856f18775e30d830df
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -39,6 +39,7 @@ accurate and fully typed.
|
|
|
39
39
|
- [Additional Options](#additional-options)
|
|
40
40
|
- [Setting the endpoint](#setting-the-endpoint)
|
|
41
41
|
- [Setting the request timeout](#setting-the-request-timeout)
|
|
42
|
+
- [Retry behavior](#retry-behavior)
|
|
42
43
|
- [Configuring the Faraday Client](#configuring-the-faraday-client)
|
|
43
44
|
- [Using the Faraday Client](#using-the-faraday-client)
|
|
44
45
|
- [Overriding the Client](#overriding-the-client)
|
|
@@ -443,6 +444,17 @@ seam = Seam.new(
|
|
|
443
444
|
|
|
444
445
|
A request that exceeds the timeout raises `Faraday::TimeoutError`.
|
|
445
446
|
|
|
447
|
+
#### Retry behavior
|
|
448
|
+
|
|
449
|
+
By default, the SDK makes up to three attempts: the initial request and two
|
|
450
|
+
retries. Retries are limited to `GET`, `HEAD`, `OPTIONS`, `PUT`, and `DELETE`
|
|
451
|
+
requests that fail because of a transport error, timeout, HTTP 429 response, or
|
|
452
|
+
HTTP 5xx response. `POST` and `PATCH` requests are not retried.
|
|
453
|
+
|
|
454
|
+
Retries use exponential backoff with jitter: approximately 200–240 ms before
|
|
455
|
+
the first retry and 400–480 ms before the second. A longer `Retry-After` header
|
|
456
|
+
is honored. The request timeout is reset for each attempt.
|
|
457
|
+
|
|
446
458
|
#### Configuring the Faraday Client
|
|
447
459
|
|
|
448
460
|
The Faraday client and retry behavior may be configured with custom initiation options
|
|
@@ -16,13 +16,45 @@ module Seam
|
|
|
16
16
|
|
|
17
17
|
attr_reader :client, :defaults
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
OPTION_NOT_PROVIDED = Object.new.freeze
|
|
20
|
+
private_constant :OPTION_NOT_PROVIDED
|
|
21
|
+
|
|
22
|
+
def initialize(client: nil, api_key: OPTION_NOT_PROVIDED, personal_access_token: OPTION_NOT_PROVIDED,
|
|
23
|
+
workspace_id: OPTION_NOT_PROVIDED, endpoint: OPTION_NOT_PROVIDED,
|
|
24
|
+
wait_for_action_attempt: OPTION_NOT_PROVIDED, timeout: OPTION_NOT_PROVIDED,
|
|
25
|
+
faraday_options: OPTION_NOT_PROVIDED, faraday_retry_options: OPTION_NOT_PROVIDED)
|
|
26
|
+
supplied_options = {
|
|
27
|
+
api_key: api_key,
|
|
28
|
+
personal_access_token: personal_access_token,
|
|
29
|
+
workspace_id: workspace_id,
|
|
30
|
+
endpoint: endpoint,
|
|
31
|
+
wait_for_action_attempt: wait_for_action_attempt,
|
|
32
|
+
timeout: timeout,
|
|
33
|
+
faraday_options: faraday_options,
|
|
34
|
+
faraday_retry_options: faraday_retry_options
|
|
35
|
+
}.reject { |_, value| value.equal?(OPTION_NOT_PROVIDED) }
|
|
36
|
+
invalid_options = supplied_options.keys - [:wait_for_action_attempt]
|
|
37
|
+
|
|
38
|
+
if client && invalid_options.any?
|
|
39
|
+
raise Http::Options::SeamInvalidOptionsError.new(
|
|
40
|
+
"The client option cannot be used with any other option, but received: #{supplied_options.keys.join(", ")}"
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
wait_for_action_attempt = true if wait_for_action_attempt.equal?(OPTION_NOT_PROVIDED)
|
|
21
45
|
@defaults = Seam::DeepHashAccessor.new({"wait_for_action_attempt" => wait_for_action_attempt})
|
|
22
46
|
|
|
23
47
|
# A client carries its own endpoint and authorization, so the auth
|
|
24
48
|
# options are only parsed when one has to be built.
|
|
25
49
|
@client = client || begin
|
|
50
|
+
api_key = nil if api_key.equal?(OPTION_NOT_PROVIDED)
|
|
51
|
+
personal_access_token = nil if personal_access_token.equal?(OPTION_NOT_PROVIDED)
|
|
52
|
+
workspace_id = nil if workspace_id.equal?(OPTION_NOT_PROVIDED)
|
|
53
|
+
endpoint = nil if endpoint.equal?(OPTION_NOT_PROVIDED)
|
|
54
|
+
timeout = nil if timeout.equal?(OPTION_NOT_PROVIDED)
|
|
55
|
+
faraday_options = {} if faraday_options.equal?(OPTION_NOT_PROVIDED)
|
|
56
|
+
faraday_retry_options = {} if faraday_retry_options.equal?(OPTION_NOT_PROVIDED)
|
|
57
|
+
|
|
26
58
|
options = Http::Options.parse_options(api_key: api_key, personal_access_token: personal_access_token,
|
|
27
59
|
workspace_id: workspace_id, endpoint: endpoint)
|
|
28
60
|
@endpoint = options[:endpoint]
|
|
@@ -13,18 +13,47 @@ module Seam
|
|
|
13
13
|
class WithoutWorkspace
|
|
14
14
|
attr_reader :client, :defaults
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
OPTION_NOT_PROVIDED = Object.new.freeze
|
|
17
|
+
private_constant :OPTION_NOT_PROVIDED
|
|
18
|
+
|
|
19
|
+
def initialize(client: nil, personal_access_token: OPTION_NOT_PROVIDED, endpoint: OPTION_NOT_PROVIDED,
|
|
20
|
+
wait_for_action_attempt: OPTION_NOT_PROVIDED, timeout: OPTION_NOT_PROVIDED,
|
|
21
|
+
faraday_options: OPTION_NOT_PROVIDED, faraday_retry_options: OPTION_NOT_PROVIDED)
|
|
22
|
+
supplied_options = {
|
|
23
|
+
personal_access_token: personal_access_token,
|
|
24
|
+
endpoint: endpoint,
|
|
25
|
+
wait_for_action_attempt: wait_for_action_attempt,
|
|
26
|
+
timeout: timeout,
|
|
27
|
+
faraday_options: faraday_options,
|
|
28
|
+
faraday_retry_options: faraday_retry_options
|
|
29
|
+
}.reject { |_, value| value.equal?(OPTION_NOT_PROVIDED) }
|
|
30
|
+
invalid_options = supplied_options.keys - [:wait_for_action_attempt]
|
|
31
|
+
|
|
32
|
+
if client && invalid_options.any?
|
|
33
|
+
raise Http::Options::SeamInvalidOptionsError.new(
|
|
34
|
+
"The client option cannot be used with any other option, but received: #{supplied_options.keys.join(", ")}"
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
wait_for_action_attempt = true if wait_for_action_attempt.equal?(OPTION_NOT_PROVIDED)
|
|
18
39
|
@wait_for_action_attempt = wait_for_action_attempt
|
|
19
40
|
@defaults = {"wait_for_action_attempt" => wait_for_action_attempt}
|
|
20
41
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
@client = client || begin
|
|
43
|
+
personal_access_token = nil if personal_access_token.equal?(OPTION_NOT_PROVIDED)
|
|
44
|
+
endpoint = nil if endpoint.equal?(OPTION_NOT_PROVIDED)
|
|
45
|
+
timeout = nil if timeout.equal?(OPTION_NOT_PROVIDED)
|
|
46
|
+
faraday_options = {} if faraday_options.equal?(OPTION_NOT_PROVIDED)
|
|
47
|
+
faraday_retry_options = {} if faraday_retry_options.equal?(OPTION_NOT_PROVIDED)
|
|
48
|
+
|
|
49
|
+
options = Http::Options.parse_without_workspace_options(personal_access_token: personal_access_token,
|
|
50
|
+
endpoint: endpoint)
|
|
51
|
+
@endpoint = options[:endpoint]
|
|
52
|
+
@auth_headers = options[:auth_headers]
|
|
25
53
|
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
Http::Request.create_faraday_client(@endpoint, @auth_headers, faraday_options,
|
|
55
|
+
faraday_retry_options, timeout: timeout)
|
|
56
|
+
end
|
|
28
57
|
end
|
|
29
58
|
|
|
30
59
|
def workspaces
|
data/lib/seam/request.rb
CHANGED
|
@@ -23,7 +23,11 @@ module Seam
|
|
|
23
23
|
|
|
24
24
|
default_faraday_retry_options = {
|
|
25
25
|
max: 2,
|
|
26
|
-
|
|
26
|
+
interval: 0.2,
|
|
27
|
+
interval_randomness: 0.2,
|
|
28
|
+
backoff_factor: 2,
|
|
29
|
+
exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed],
|
|
30
|
+
retry_statuses: [429] + (500..599).to_a
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
faraday_retry_options = default_faraday_retry_options.merge(faraday_retry_options)
|
data/lib/seam/version.rb
CHANGED