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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a900e1dbd5b83ee9c188064f4dd1cbb4ae3c0b70c7fb022b99441248d6e1f053
4
- data.tar.gz: '04182a6dd0f06b10d1198d5a71ffda24e2bacec06a4b60d75d2df7c36e7ab8e1'
3
+ metadata.gz: 2b94008b86b31b1f480fc2c3276075bc61d83a74dd09ea0af2b7831f39e603c3
4
+ data.tar.gz: 1f4a039c2309d9b31c82cb9c295c09fb925161150f64eede25fcad60e35c89c0
5
5
  SHA512:
6
- metadata.gz: e62a991868e5415256b134dcc34161535f088b8e285e2129644e210dade3a9a365f7e812c51b201f327bc4a1c61490dbbe1d806485f540d56e3921011b45c3d2
7
- data.tar.gz: 66a2f9eb59caeb846ed98d48a6717a2a9a411361455a53d294daeb6b402048c58796da36dbb62fb7b7bef4a305092d30ed354443811dcca133d10bd0af78ac6c
6
+ metadata.gz: c23cbe8e1da6b13568c3cdb1676d7e19c68068aaa99b651ae1915ce4ec04eb776def06af72e3b592381e200e9dd85dbc20e7d568ebe60ea5092e17b27151b67c
7
+ data.tar.gz: 23f38b1e3c55349694570c17aa70a1d3e6696336d04ec0506ba4758360fdc2a651f9229263efb2c5168f95903f3525c85163ebb1b92de1856f18775e30d830df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seam (2.138.0)
4
+ seam (2.139.0)
5
5
  faraday (~> 2.7)
6
6
  faraday-retry (~> 2.2)
7
7
  svix (~> 1.30)
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
- def initialize(client: nil, api_key: nil, personal_access_token: nil, workspace_id: nil, endpoint: nil,
20
- wait_for_action_attempt: true, timeout: nil, faraday_options: {}, faraday_retry_options: {})
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
- def initialize(personal_access_token: nil, endpoint: nil, wait_for_action_attempt: true, timeout: nil,
17
- faraday_options: {}, faraday_retry_options: {})
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
- options = Http::Options.parse_without_workspace_options(personal_access_token: personal_access_token,
22
- endpoint: endpoint)
23
- @endpoint = options[:endpoint]
24
- @auth_headers = options[:auth_headers]
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
- @client = Http::Request.create_faraday_client(@endpoint, @auth_headers, faraday_options,
27
- faraday_retry_options, timeout: timeout)
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
- backoff_factor: 2
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Seam
4
- VERSION = "2.138.0"
4
+ VERSION = "2.139.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seam
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.138.0
4
+ version: 2.139.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seam Labs, Inc.