speakeasy_client_sdk_ruby 1.18.0 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sdk/sdkconfiguration.rb +2 -2
- data/lib/speakeasy_client_sdk_ruby.rb +0 -1
- metadata +2 -3
- data/lib/sdk/utils/retries.rb +0 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed7fd6636d80c8c070778dc2e81fa936effdc65885f45e5cc9fcd55180149fdd
|
4
|
+
data.tar.gz: 4306b5471ef4fca692ed306e57d9ed7d0e759d88bbdfa9292e64835601611c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: babce1a929e077a3136cac709119ee64243a8a9f8112ba8ba629b59d89777bba0f1fd72096acd01a1a25cdf4d68a305e97bd853955bd27ce0e31f5b8adf9b2a2
|
7
|
+
data.tar.gz: b0c6c4711f21f254340739700e6291c386ca6fe30455a2c0eb985c6c1fe45ddbb49a827280559b017f3fdb37b0c3399d67264358b561cd904c25f872a46ac479
|
data/lib/sdk/sdkconfiguration.rb
CHANGED
@@ -38,8 +38,8 @@ module OpenApiSDK
|
|
38
38
|
@server = server_url.nil? ? '' : server_url
|
39
39
|
@language = 'ruby'
|
40
40
|
@openapi_doc_version = '0.3.0'
|
41
|
-
@sdk_version = '1.
|
42
|
-
@gen_version = '2.
|
41
|
+
@sdk_version = '1.19.0'
|
42
|
+
@gen_version = '2.82.0'
|
43
43
|
end
|
44
44
|
|
45
45
|
sig { returns([String, T::Hash[Symbol, String]]) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speakeasy_client_sdk_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Speakeasy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -175,7 +175,6 @@ files:
|
|
175
175
|
- lib/sdk/sdk.rb
|
176
176
|
- lib/sdk/sdkconfiguration.rb
|
177
177
|
- lib/sdk/utils/metadata_fields.rb
|
178
|
-
- lib/sdk/utils/retries.rb
|
179
178
|
- lib/sdk/utils/utils.rb
|
180
179
|
- lib/speakeasy_client_sdk_ruby.rb
|
181
180
|
homepage: https://github.com/speakeasy-api/openapi-generation
|
data/lib/sdk/utils/retries.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
2
|
-
|
3
|
-
# typed: true
|
4
|
-
# frozen_string_literal: true
|
5
|
-
|
6
|
-
require 'sorbet-runtime'
|
7
|
-
|
8
|
-
module SpeakeasyClientSDK
|
9
|
-
class BackoffStrategy
|
10
|
-
extend T::Sig
|
11
|
-
|
12
|
-
attr_accessor :initial_interval, :max_interval, :exponent, :max_elapsed_time
|
13
|
-
|
14
|
-
sig { params(initial_interval: Integer, max_interval: Integer, exponent: Float, max_elapsed_time: Integer).void }
|
15
|
-
def initialize(initial_interval, max_interval, exponent, max_elapsed_time)
|
16
|
-
@initial_interval = initial_interval
|
17
|
-
@max_interval = max_interval
|
18
|
-
@exponent = exponent
|
19
|
-
@max_elapsed_time = max_elapsed_time
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class RetryConfig
|
24
|
-
extend T::Sig
|
25
|
-
|
26
|
-
attr_accessor :strategy, :backoff, :retry_connection_errors
|
27
|
-
|
28
|
-
sig { params(strategy: String, retry_connection_errors: bool).void }
|
29
|
-
def initialize(strategy, retry_connection_errors)
|
30
|
-
@strategy = strategy
|
31
|
-
@retry_connection_errors = retry_connection_errors
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class RetriesContainer
|
36
|
-
extend T::Sig
|
37
|
-
|
38
|
-
attr_accessor :config, :status_codes
|
39
|
-
|
40
|
-
sig { params(config: RetryConfig, status_codes: Array[String]).void }
|
41
|
-
def initialize(config, status_codes)
|
42
|
-
@config = config
|
43
|
-
@status_codes = status_codes
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class TemporaryError < StandardError
|
48
|
-
extend T::Sig
|
49
|
-
|
50
|
-
attr_accessor :response
|
51
|
-
|
52
|
-
sig { params(response: requests.Response).void }
|
53
|
-
def initialize(response)
|
54
|
-
@response = response
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class PermanentError < StandardError
|
59
|
-
extend T::Sig
|
60
|
-
|
61
|
-
attr_accessor :inner
|
62
|
-
|
63
|
-
sig { params(inner: StandardError).void }
|
64
|
-
def initialize(inner)
|
65
|
-
@inner = inner
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.retry(fun, retries)
|
70
|
-
if retries.config.strategy == 'backoff'
|
71
|
-
do_request = lambda do
|
72
|
-
begin
|
73
|
-
res = fun.call
|
74
|
-
retries.status_codes.each do |code|
|
75
|
-
if code.upcase.include? 'X'
|
76
|
-
code_range = code[0].to_i
|
77
|
-
s = res.status_code / 100
|
78
|
-
raise TemporaryError, res if s >= code_range && s < code_range + 1
|
79
|
-
else
|
80
|
-
parsed_code = code.to_i
|
81
|
-
raise TemporaryError, res if res.status_code == parsed_code
|
82
|
-
end
|
83
|
-
end
|
84
|
-
rescue Faraday::ConnectionFailed => e
|
85
|
-
if !retries.config.config.retry_connection_errors
|
86
|
-
raise
|
87
|
-
else
|
88
|
-
raise PermanentError, e
|
89
|
-
end
|
90
|
-
rescue Faraday::TimeoutError => e
|
91
|
-
if !retries.config.config.retry_connection_errors
|
92
|
-
raise
|
93
|
-
else
|
94
|
-
raise PermanentError, e
|
95
|
-
end
|
96
|
-
rescue TemporaryError
|
97
|
-
raise
|
98
|
-
rescue StandardError => e
|
99
|
-
raise PermanentError, e
|
100
|
-
end
|
101
|
-
return res
|
102
|
-
end
|
103
|
-
retry_with_backoff(do_request, retries.config.backoff.initial_interval,
|
104
|
-
retries.config.backoff.max_interval, retries.config.backoff.exponent,
|
105
|
-
retries.config.backoff.max_elapsed_time)
|
106
|
-
else
|
107
|
-
fun.call
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.retry_with_backoff(fun, initial_interval = 500, max_interval = 60_000,
|
112
|
-
exponent = 1.5, max_elapsed_time = 3_600_000)
|
113
|
-
start = round(Time.now.to_i * 1000)
|
114
|
-
x = 0
|
115
|
-
loop do
|
116
|
-
return fun.call
|
117
|
-
rescue PermanentError => e
|
118
|
-
raise e.inner
|
119
|
-
rescue TemporaryError => e
|
120
|
-
now = round(Time.now.to_i * 1000)
|
121
|
-
return e.response if now - start > max_elapsed_time
|
122
|
-
|
123
|
-
sleep = ((initial_interval / 1000) * exponent**x + rand)
|
124
|
-
sleep = max_interval / 1000 if sleep > max_interval / 1000
|
125
|
-
|
126
|
-
sleep(sleep)
|
127
|
-
x += 1
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|