trino-client 2.2.5 → 2.3.1
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/ChangeLog.md +13 -0
- data/README.md +14 -16
- data/lib/trino/client/client.rb +12 -4
- data/lib/trino/client/faraday_client.rb +27 -26
- data/lib/trino/client/query.rb +10 -6
- data/lib/trino/client/statement_client.rb +55 -29
- data/lib/trino/client/version.rb +1 -1
- data/trino-client.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63abc1ae1264778be0bd76aa0fb7225376a4a2169e6224823bfcdf551e8de741
|
|
4
|
+
data.tar.gz: c4a1cc7797f2f6e64602a7db829484942f437efde7fd568e82a416c48b26125a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ce7ae32f6e438f0558a4b2346b2480e860fc2a6111287c0e9c43f1226af7c832cca0a69a2f7a1ae19e02a9ef6d9bf1b9198881ebcda516d4b77d6ee3dece51b
|
|
7
|
+
data.tar.gz: 3bf7c96b9382ce83830902657b5eff930e63621afc70dda55aa21e71185e36057e5d68d4a99cec29392ee6e8411986bd06ee2099ccc1781cd78adde36eb5d98a
|
data/ChangeLog.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
trino-client-ruby
|
|
2
2
|
====
|
|
3
|
+
## 2.3.0
|
|
4
|
+
- Reuse a Faraday client per Trino::Client instance @p623 (#168)
|
|
5
|
+
|
|
6
|
+
## 2.2.6
|
|
7
|
+
- fix: improve POST retry tests and document idempotency assumption ([#159](https://github.com/treasure-data/trino-client-ruby/issues/159)) [[e64c2a9](https://github.com/treasure-data/trino-client-ruby/commit/e64c2a9)]
|
|
8
|
+
- Add retry to POST /v1/statement ([#157](https://github.com/treasure-data/trino-client-ruby/issues/157)) [[64a5c66](https://github.com/treasure-data/trino-client-ruby/commit/64a5c66)]
|
|
9
|
+
- Update psych requirement from ~> 3 to ~> 5 ([#140](https://github.com/treasure-data/trino-client-ruby/issues/140)) [[eeb3333](https://github.com/treasure-data/trino-client-ruby/commit/eeb3333)]
|
|
10
|
+
- Update dependabot.yaml to change the update interval from weekly to monthly and set commit message prefix to "chore". [[2fde3f2](https://github.com/treasure-data/trino-client-ruby/commit/2fde3f2)]
|
|
11
|
+
- Minor fix [[db03c07](https://github.com/treasure-data/trino-client-ruby/commit/db03c07)]
|
|
12
|
+
- Update addressable requirement from ~> 2.8.1 to ~> 2.9.0 [[1a56064](https://github.com/treasure-data/trino-client-ruby/commit/1a56064)]
|
|
13
|
+
- Update README.md for release instructions [skip ci] [[dda6a06](https://github.com/treasure-data/trino-client-ruby/commit/dda6a06)]
|
|
14
|
+
- v2.2.5 [[12ce8e8](https://github.com/treasure-data/trino-client-ruby/commit/12ce8e8)]
|
|
15
|
+
|
|
3
16
|
## 2.2.5
|
|
4
17
|
- Merge pull request [#155](https://github.com/treasure-data/trino-client-ruby/issues/155) from murakami-ta/add-http-debug-logger-option [[143a801](https://github.com/treasure-data/trino-client-ruby/commit/143a801)]
|
|
5
18
|
- Fix http_debug_logger test to work with both Faraday 1 and 2 [[0976be7](https://github.com/treasure-data/trino-client-ruby/commit/0976be7)]
|
data/README.md
CHANGED
|
@@ -88,8 +88,8 @@ $ bundle exec rake modelgen:latest
|
|
|
88
88
|
|
|
89
89
|
## Options
|
|
90
90
|
|
|
91
|
-
* **server** sets address (and port) of a Trino coordinator server.
|
|
92
|
-
* **ssl** enables https.
|
|
91
|
+
* **server** sets address (and port) of a Trino coordinator server. Changes after client initialization are not applied; create a new client to change this option.
|
|
92
|
+
* **ssl** enables https. Changes after client initialization are not applied; create a new client to change this option.
|
|
93
93
|
* Setting `true` enables SSL and verifies server certificate using system's built-in certificates.
|
|
94
94
|
* Setting `{verify: false}` enables SSL but doesn't verify server certificate.
|
|
95
95
|
* Setting a Hash object enables SSL and verify server certificate with options:
|
|
@@ -104,20 +104,21 @@ $ bundle exec rake modelgen:latest
|
|
|
104
104
|
* **client_info** sets client info to queries. It can be a string to pass a raw string, or an object that can be encoded to JSON.
|
|
105
105
|
* **client_tags** sets client tags to queries. It needs to be an array of strings. The tags are shown on web interface.
|
|
106
106
|
* **user** sets user name to connect to a Trino.
|
|
107
|
-
* **password** sets a password to connect to Trino using basic auth.
|
|
107
|
+
* **password** sets a password to connect to Trino using basic auth. Requires the client's connection to use HTTPS.
|
|
108
108
|
* **time_zone** sets time zone of queries. Time zone affects some functions such as `format_datetime`.
|
|
109
109
|
* **language** sets language of queries. Language affects some functions such as `format_datetime`.
|
|
110
110
|
* **properties** set session properties. Session properties affect internal behavior such as `hive.force_local_scheduling: true`, `raptor.reader_stream_buffer_size: "32MB"`, etc.
|
|
111
111
|
* **query_timeout** sets timeout in seconds for the entire query execution (from the first API call until there're no more output data). If timeout happens, client raises TrinoQueryTimeoutError. Default is nil (disabled).
|
|
112
112
|
* **plan_timeout** sets timeout in seconds for query planning execution (from the first API call until result columns become available). If timeout happens, client raises TrinoQueryTimeoutError. Default is nil (disabled).
|
|
113
113
|
* **http_headers** sets custom HTTP headers. It must be a Hash of string to string.
|
|
114
|
-
* **http_proxy** sets host:port of a HTTP proxy server.
|
|
115
|
-
* **http_debug** enables debug message to STDOUT for each HTTP requests.
|
|
116
|
-
* **http_debug_logger** sets a custom `Logger` instance for HTTP debug logs. Requires **http_debug** to be `true`.
|
|
114
|
+
* **http_proxy** sets host:port of a HTTP proxy server. Changes after client initialization are not applied; create a new client to change this option.
|
|
115
|
+
* **http_debug** enables debug message to STDOUT for each HTTP requests. Changes after client initialization are not applied; create a new client to change this option.
|
|
116
|
+
* **http_debug_logger** sets a custom `Logger` instance for HTTP debug logs. Requires **http_debug** to be `true`. Changes after client initialization are not applied; create a new client to change this option.
|
|
117
117
|
* **http_open_timeout** sets timeout in seconds to open new HTTP connection.
|
|
118
118
|
* **http_timeout** sets timeout in seconds to read data from a server.
|
|
119
|
-
* **gzip** enables gzip compression.
|
|
120
|
-
* **follow_redirect** enables HTTP redirection support.
|
|
119
|
+
* **gzip** enables gzip compression. Changes after client initialization are not applied; create a new client to change this option.
|
|
120
|
+
* **follow_redirect** enables HTTP redirection support. Changes after client initialization are not applied; create a new client to change this option.
|
|
121
|
+
* **faraday_adapter** sets the Faraday adapter to use. Default is `Faraday.default_adapter`. To reuse persistent HTTP connections, install `faraday-net_http_persistent` and specify `:net_http_persistent`. Changes after client initialization are not applied; create a new client to change this option.
|
|
121
122
|
* **model_version** set the Trino version to which a job is submitted. Supported versions are 351, 316, 303, 0.205, 0.178, 0.173, 0.153 and 0.149. Default is 351.
|
|
122
123
|
|
|
123
124
|
See [RDoc](http://www.rubydoc.info/gems/presto-client/) for the full documentation.
|
|
@@ -126,20 +127,17 @@ See [RDoc](http://www.rubydoc.info/gems/presto-client/) for the full documentati
|
|
|
126
127
|
|
|
127
128
|
### Releasing a new version
|
|
128
129
|
|
|
129
|
-
1.
|
|
130
|
-
2. Run the following command which will update `ChangeLog.md` file automatically.
|
|
130
|
+
1. Run the following command which will prompt for the new version, update `lib/trino/client/version.rb`, and generate/let you edit `ChangeLog.md`.
|
|
131
131
|
```
|
|
132
132
|
$ ruby release.rb
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
2. Commit and tag
|
|
136
136
|
```
|
|
137
137
|
$ git commit -am "vX.Y.Z"
|
|
138
138
|
$ git tag "vX.Y.Z"
|
|
139
|
-
|
|
139
|
+
$ git push origin master
|
|
140
|
+
$ git push --tags
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
$ ruby publish.rb
|
|
145
|
-
```
|
|
143
|
+
Pushing a `v*` tag triggers the GitHub Actions publisher workflow, which automatically builds and publishes the gem to RubyGems.org.
|
data/lib/trino/client/client.rb
CHANGED
|
@@ -19,12 +19,20 @@ module Trino::Client
|
|
|
19
19
|
require 'trino/client/query'
|
|
20
20
|
|
|
21
21
|
class Client
|
|
22
|
+
# Creates a reusable Faraday connection using the initial options.
|
|
23
|
+
# Connection settings are not reapplied after initialization.
|
|
24
|
+
# These include server, ssl, proxy, and faraday_adapter; see the README for the full list.
|
|
25
|
+
# Create a new Client to change these settings.
|
|
26
|
+
#
|
|
27
|
+
# Query-specific headers, including Basic Auth, use the options at query start.
|
|
28
|
+
# Password authentication requires the actual connection to use HTTPS, regardless of later changes to options[:ssl].
|
|
22
29
|
def initialize(options)
|
|
23
30
|
@options = options
|
|
31
|
+
@faraday = Trino::Client.faraday_client(options)
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
def query(query, &block)
|
|
27
|
-
q = Query.start(query, @options)
|
|
35
|
+
q = Query.start(query, @options, @faraday)
|
|
28
36
|
if block
|
|
29
37
|
begin
|
|
30
38
|
yield q
|
|
@@ -37,15 +45,15 @@ module Trino::Client
|
|
|
37
45
|
end
|
|
38
46
|
|
|
39
47
|
def resume_query(next_uri)
|
|
40
|
-
return Query.resume(next_uri, @options)
|
|
48
|
+
return Query.resume(next_uri, @options, @faraday)
|
|
41
49
|
end
|
|
42
50
|
|
|
43
51
|
def kill(query_id)
|
|
44
|
-
return Query.kill(query_id, @options)
|
|
52
|
+
return Query.kill(query_id, @options, @faraday)
|
|
45
53
|
end
|
|
46
54
|
|
|
47
55
|
def run(query)
|
|
48
|
-
q = Query.start(query, @options)
|
|
56
|
+
q = Query.start(query, @options, @faraday)
|
|
49
57
|
begin
|
|
50
58
|
columns = q.columns
|
|
51
59
|
if columns.empty?
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
16
|
module Trino::Client
|
|
17
|
-
FARADAY1_USED = Faraday::VERSION.start_with?("1.")
|
|
18
|
-
private_constant :FARADAY1_USED
|
|
19
17
|
|
|
18
|
+
require 'base64'
|
|
20
19
|
require 'cgi'
|
|
21
20
|
|
|
22
21
|
module TrinoHeaders
|
|
@@ -77,14 +76,6 @@ module Trino::Client
|
|
|
77
76
|
faraday_options[:ssl] = ssl if ssl
|
|
78
77
|
|
|
79
78
|
faraday = Faraday.new(faraday_options) do |faraday|
|
|
80
|
-
if options[:user] && options[:password]
|
|
81
|
-
# https://lostisland.github.io/faraday/middleware/authentication
|
|
82
|
-
if FARADAY1_USED
|
|
83
|
-
faraday.request(:basic_auth, options[:user], options[:password])
|
|
84
|
-
else
|
|
85
|
-
faraday.request :authorization, :basic, options[:user], options[:password]
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
79
|
if options[:follow_redirect]
|
|
89
80
|
faraday.response :follow_redirects
|
|
90
81
|
end
|
|
@@ -92,11 +83,10 @@ module Trino::Client
|
|
|
92
83
|
faraday.request :gzip
|
|
93
84
|
end
|
|
94
85
|
faraday.response :logger, options[:http_debug_logger] if options[:http_debug]
|
|
95
|
-
faraday.adapter Faraday.default_adapter
|
|
86
|
+
faraday.adapter(options[:faraday_adapter] || Faraday.default_adapter)
|
|
96
87
|
end
|
|
97
88
|
|
|
98
89
|
faraday.headers.merge!(HEADERS)
|
|
99
|
-
faraday.headers.merge!(optional_headers(options))
|
|
100
90
|
|
|
101
91
|
return faraday
|
|
102
92
|
end
|
|
@@ -129,71 +119,82 @@ module Trino::Client
|
|
|
129
119
|
return ssl
|
|
130
120
|
end
|
|
131
121
|
|
|
132
|
-
def self.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
def self.build_query_headers(options, faraday:)
|
|
123
|
+
if options[:password] && faraday.url_prefix.scheme != "https"
|
|
124
|
+
raise ArgumentError, "Protocol must be https when passing a password"
|
|
125
|
+
end
|
|
126
|
+
use_presto_headers = false
|
|
127
|
+
if options[:model_version] && options[:model_version].to_i < 351
|
|
128
|
+
use_presto_headers = true
|
|
136
129
|
end
|
|
137
130
|
|
|
138
131
|
headers = {}
|
|
132
|
+
|
|
133
|
+
if options[:user] && options[:password]
|
|
134
|
+
credentials = Base64.strict_encode64(
|
|
135
|
+
"#{options[:user]}:#{options[:password]}"
|
|
136
|
+
)
|
|
137
|
+
headers["Authorization"] = "Basic #{credentials}"
|
|
138
|
+
end
|
|
139
|
+
|
|
139
140
|
if v = options[:user]
|
|
140
|
-
if
|
|
141
|
+
if use_presto_headers
|
|
141
142
|
headers[PrestoHeaders::PRESTO_USER] = v
|
|
142
143
|
else
|
|
143
144
|
headers[TrinoHeaders::TRINO_USER] = v
|
|
144
145
|
end
|
|
145
146
|
end
|
|
146
147
|
if v = options[:source]
|
|
147
|
-
if
|
|
148
|
+
if use_presto_headers
|
|
148
149
|
headers[PrestoHeaders::PRESTO_SOURCE] = v
|
|
149
150
|
else
|
|
150
151
|
headers[TrinoHeaders::TRINO_SOURCE] = v
|
|
151
152
|
end
|
|
152
153
|
end
|
|
153
154
|
if v = options[:catalog]
|
|
154
|
-
if
|
|
155
|
+
if use_presto_headers
|
|
155
156
|
headers[PrestoHeaders::PRESTO_CATALOG] = v
|
|
156
157
|
else
|
|
157
158
|
headers[TrinoHeaders::TRINO_CATALOG] = v
|
|
158
159
|
end
|
|
159
160
|
end
|
|
160
161
|
if v = options[:schema]
|
|
161
|
-
if
|
|
162
|
+
if use_presto_headers
|
|
162
163
|
headers[PrestoHeaders::PRESTO_SCHEMA] = v
|
|
163
164
|
else
|
|
164
165
|
headers[TrinoHeaders::TRINO_SCHEMA] = v
|
|
165
166
|
end
|
|
166
167
|
end
|
|
167
168
|
if v = options[:time_zone]
|
|
168
|
-
if
|
|
169
|
+
if use_presto_headers
|
|
169
170
|
headers[PrestoHeaders::PRESTO_TIME_ZONE] = v
|
|
170
171
|
else
|
|
171
172
|
headers[TrinoHeaders::TRINO_TIME_ZONE] = v
|
|
172
173
|
end
|
|
173
174
|
end
|
|
174
175
|
if v = options[:language]
|
|
175
|
-
if
|
|
176
|
+
if use_presto_headers
|
|
176
177
|
headers[PrestoHeaders::PRESTO_LANGUAGE] = v
|
|
177
178
|
else
|
|
178
179
|
headers[TrinoHeaders::TRINO_LANGUAGE] = v
|
|
179
180
|
end
|
|
180
181
|
end
|
|
181
182
|
if v = options[:properties]
|
|
182
|
-
if
|
|
183
|
+
if use_presto_headers
|
|
183
184
|
headers[PrestoHeaders::PRESTO_SESSION] = encode_properties(v)
|
|
184
185
|
else
|
|
185
186
|
headers[TrinoHeaders::TRINO_SESSION] = encode_properties(v)
|
|
186
187
|
end
|
|
187
188
|
end
|
|
188
189
|
if v = options[:client_info]
|
|
189
|
-
if
|
|
190
|
+
if use_presto_headers
|
|
190
191
|
headers[PrestoHeaders::PRESTO_CLIENT_INFO] = encode_client_info(v)
|
|
191
192
|
else
|
|
192
193
|
headers[TrinoHeaders::TRINO_CLIENT_INFO] = encode_client_info(v)
|
|
193
194
|
end
|
|
194
195
|
end
|
|
195
196
|
if v = options[:client_tags]
|
|
196
|
-
if
|
|
197
|
+
if use_presto_headers
|
|
197
198
|
headers[PrestoHeaders::PRESTO_CLIENT_TAGS] = encode_client_tags(v)
|
|
198
199
|
else
|
|
199
200
|
headers[TrinoHeaders::TRINO_CLIENT_TAGS] = encode_client_tags(v)
|
|
@@ -245,6 +246,6 @@ module Trino::Client
|
|
|
245
246
|
Array(tags).join(",")
|
|
246
247
|
end
|
|
247
248
|
|
|
248
|
-
private_class_method :faraday_ssl_options, :
|
|
249
|
+
private_class_method :faraday_ssl_options, :encode_properties, :encode_client_info, :encode_client_tags
|
|
249
250
|
|
|
250
251
|
end
|
data/lib/trino/client/query.rb
CHANGED
|
@@ -25,17 +25,21 @@ module Trino::Client
|
|
|
25
25
|
require 'trino/client/statement_client'
|
|
26
26
|
|
|
27
27
|
class Query
|
|
28
|
-
def self.start(query, options)
|
|
29
|
-
|
|
28
|
+
def self.start(query, options, faraday = nil)
|
|
29
|
+
faraday ||= faraday_client(options)
|
|
30
|
+
new StatementClient.new(faraday, query, options)
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
def self.resume(next_uri, options)
|
|
33
|
-
|
|
33
|
+
def self.resume(next_uri, options, faraday = nil)
|
|
34
|
+
faraday ||= faraday_client(options)
|
|
35
|
+
new StatementClient.new(faraday, nil, options, next_uri)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
def self.kill(query_id, options)
|
|
37
|
-
faraday
|
|
38
|
+
def self.kill(query_id, options, faraday = nil)
|
|
39
|
+
faraday ||= faraday_client(options)
|
|
40
|
+
headers = Trino::Client.build_query_headers(options, faraday: faraday)
|
|
38
41
|
response = faraday.delete do |req|
|
|
42
|
+
req.headers.merge!(headers)
|
|
39
43
|
req.url "/v1/query/#{query_id}"
|
|
40
44
|
end
|
|
41
45
|
return response.status / 100 == 2
|
|
@@ -26,8 +26,11 @@ module Trino::Client
|
|
|
26
26
|
:max_nesting => false
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
RETRYABLE_STATUSES = [502, 503, 504]
|
|
30
|
+
|
|
29
31
|
def initialize(faraday, query, options, next_uri=nil)
|
|
30
32
|
@faraday = faraday
|
|
33
|
+
@headers = Trino::Client.build_query_headers(options, faraday: @faraday)
|
|
31
34
|
|
|
32
35
|
@options = options
|
|
33
36
|
@query = query
|
|
@@ -66,16 +69,32 @@ module Trino::Client
|
|
|
66
69
|
|
|
67
70
|
def post_query_request!
|
|
68
71
|
uri = "/v1/statement"
|
|
69
|
-
response =
|
|
70
|
-
|
|
72
|
+
response = with_retry_loop do
|
|
73
|
+
begin
|
|
74
|
+
r = @faraday.post do |req|
|
|
75
|
+
req.url uri
|
|
76
|
+
req.headers.merge!(@headers)
|
|
71
77
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
req.body = @query
|
|
79
|
+
init_request(req)
|
|
80
|
+
end
|
|
81
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed
|
|
82
|
+
# POST /v1/statement is not idempotent; retrying transport-level errors
|
|
83
|
+
# (timeouts/connection failures) can submit duplicate queries. This is
|
|
84
|
+
# intentional under the assumption the failure happened before Trino
|
|
85
|
+
# received the request (e.g. rejected by a load balancer upstream).
|
|
86
|
+
throw :retry_with_backoff
|
|
87
|
+
rescue => e
|
|
88
|
+
exception! e
|
|
89
|
+
end
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
if r.status == 200
|
|
92
|
+
r
|
|
93
|
+
elsif RETRYABLE_STATUSES.include?(r.status)
|
|
94
|
+
throw :retry_with_backoff
|
|
95
|
+
else
|
|
96
|
+
exception! TrinoHttpError.new(r.status, "Failed to start query: #{r.body} (#{r.status})")
|
|
97
|
+
end
|
|
79
98
|
end
|
|
80
99
|
|
|
81
100
|
@results_headers = response.headers
|
|
@@ -189,31 +208,12 @@ module Trino::Client
|
|
|
189
208
|
|
|
190
209
|
private :parse_body
|
|
191
210
|
|
|
192
|
-
def
|
|
211
|
+
def with_retry_loop
|
|
193
212
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
194
213
|
attempts = 0
|
|
195
214
|
|
|
196
215
|
loop do
|
|
197
|
-
|
|
198
|
-
response = @faraday.get(uri)
|
|
199
|
-
rescue Faraday::TimeoutError, Faraday::ConnectionFailed
|
|
200
|
-
# temporally error to retry
|
|
201
|
-
response = nil
|
|
202
|
-
rescue => e
|
|
203
|
-
exception! e
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
if response
|
|
207
|
-
if response.status == 200 && !response.body.to_s.empty?
|
|
208
|
-
return response
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
# retry if 502, 503, 504 according to the trino protocol
|
|
212
|
-
unless [502, 503, 504].include?(response.status)
|
|
213
|
-
# deterministic error
|
|
214
|
-
exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}")
|
|
215
|
-
end
|
|
216
|
-
end
|
|
216
|
+
catch(:retry_with_backoff) { return yield }
|
|
217
217
|
|
|
218
218
|
raise_if_timeout!
|
|
219
219
|
|
|
@@ -226,6 +226,30 @@ module Trino::Client
|
|
|
226
226
|
exception! TrinoHttpError.new(408, "Trino API error due to timeout")
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
+
private :with_retry_loop
|
|
230
|
+
|
|
231
|
+
def faraday_get_with_retry(uri)
|
|
232
|
+
with_retry_loop do
|
|
233
|
+
begin
|
|
234
|
+
response = @faraday.get(uri) do |req|
|
|
235
|
+
req.headers.merge!(@headers)
|
|
236
|
+
end
|
|
237
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed
|
|
238
|
+
throw :retry_with_backoff
|
|
239
|
+
rescue => e
|
|
240
|
+
exception! e
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
if response.status == 200 && !response.body.to_s.empty?
|
|
244
|
+
response
|
|
245
|
+
elsif RETRYABLE_STATUSES.include?(response.status)
|
|
246
|
+
throw :retry_with_backoff
|
|
247
|
+
else
|
|
248
|
+
exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}")
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
229
253
|
def raise_if_timeout!
|
|
230
254
|
if @started_at
|
|
231
255
|
return if finished?
|
|
@@ -258,6 +282,7 @@ module Trino::Client
|
|
|
258
282
|
def cancel_leaf_stage
|
|
259
283
|
if uri = @results.partial_cancel_uri
|
|
260
284
|
@faraday.delete do |req|
|
|
285
|
+
req.headers.merge!(@headers)
|
|
261
286
|
req.url uri
|
|
262
287
|
end
|
|
263
288
|
end
|
|
@@ -271,6 +296,7 @@ module Trino::Client
|
|
|
271
296
|
begin
|
|
272
297
|
if uri = @results.next_uri
|
|
273
298
|
@faraday.delete do |req|
|
|
299
|
+
req.headers.merge!(@headers)
|
|
274
300
|
req.url uri
|
|
275
301
|
end
|
|
276
302
|
end
|
data/lib/trino/client/version.rb
CHANGED
data/trino-client.gemspec
CHANGED
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |gem|
|
|
|
29
29
|
gem.add_development_dependency "rake", [">= 0.9.2", "< 14.0"]
|
|
30
30
|
gem.add_development_dependency "rspec", "~> 3.13.0"
|
|
31
31
|
gem.add_development_dependency "webmock", ["~> 3.0"]
|
|
32
|
-
gem.add_development_dependency "addressable", "~> 2.
|
|
32
|
+
gem.add_development_dependency "addressable", "~> 2.9.0"
|
|
33
33
|
gem.add_development_dependency "simplecov", "~> 0.22.0"
|
|
34
34
|
gem.add_development_dependency "standard", "~> 1.54.0"
|
|
35
|
-
gem.add_development_dependency "psych", "~>
|
|
35
|
+
gem.add_development_dependency "psych", "~> 5"
|
|
36
36
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trino-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -126,14 +126,14 @@ dependencies:
|
|
|
126
126
|
requirements:
|
|
127
127
|
- - "~>"
|
|
128
128
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: 2.
|
|
129
|
+
version: 2.9.0
|
|
130
130
|
type: :development
|
|
131
131
|
prerelease: false
|
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
|
133
133
|
requirements:
|
|
134
134
|
- - "~>"
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: 2.
|
|
136
|
+
version: 2.9.0
|
|
137
137
|
- !ruby/object:Gem::Dependency
|
|
138
138
|
name: simplecov
|
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -168,14 +168,14 @@ dependencies:
|
|
|
168
168
|
requirements:
|
|
169
169
|
- - "~>"
|
|
170
170
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '
|
|
171
|
+
version: '5'
|
|
172
172
|
type: :development
|
|
173
173
|
prerelease: false
|
|
174
174
|
version_requirements: !ruby/object:Gem::Requirement
|
|
175
175
|
requirements:
|
|
176
176
|
- - "~>"
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: '
|
|
178
|
+
version: '5'
|
|
179
179
|
description: Trino client library
|
|
180
180
|
email:
|
|
181
181
|
- sf@treasure-data.com
|