dor-services-client 13.3.0 → 13.4.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: 0efe22194315ac58c5725e36126edd74d5ff09c465d1e8ccc3af0c94756e2ab3
4
- data.tar.gz: dc60c7fb4f7410e878a257447f3fa9bdcb2aaadf639a769f5f12257855e0f900
3
+ metadata.gz: 9fc7a961142bc17fc963a387e6ee067b7c682eebebe455b26a7fde3f1d77ab13
4
+ data.tar.gz: 68c9d80398a759ae79b010d9391ed5b21f3478db4d9a80868f497ecdeabffa73
5
5
  SHA512:
6
- metadata.gz: 9cf0562b1d1350a1aeeba117fed6ff4d1e03ca774afc937dc9e0ac1d9f7b833366529c38130af1584cc97837b616dd09cad967f872928e102328a0c8e811041e
7
- data.tar.gz: 8de967354fb73c2a12b627be58f1caa785ce3e4b3349293d43cae8012606e3b914a40cd3d3126cbea7a395c8171b89f31263193ecb7f8999c036daa3e4ad32ba
6
+ metadata.gz: 9c4d4996966dd96f18c09ed4e5d59183e7400b2f794b113df3c722d451c61aec1e4dfecca6b4ae80eb23579b2208b9eabac3b38daa5c0f6b9f6c46cf40fb05df
7
+ data.tar.gz: 99ab68808e096af0d98046f79e461049bc1d7447a8c939deee07af50ceb68d20c247b8aadbd2b48c26aa4fdd27fddd10f3bb29e79c3fb23bedea0e2589ffa83f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (13.3.0)
4
+ dor-services-client (13.4.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  cocina-models (~> 0.93.0)
7
7
  deprecation
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (7.1.1)
15
+ activesupport (7.1.2)
16
16
  base64
17
17
  bigdecimal
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -26,7 +26,7 @@ GEM
26
26
  public_suffix (>= 2.0.2, < 6.0)
27
27
  ast (2.4.2)
28
28
  attr_extras (7.1.0)
29
- base64 (0.1.1)
29
+ base64 (0.2.0)
30
30
  bigdecimal (3.1.4)
31
31
  byebug (11.1.3)
32
32
  cocina-models (0.93.0)
@@ -54,7 +54,7 @@ GEM
54
54
  activesupport
55
55
  diff-lcs (1.5.0)
56
56
  docile (1.4.0)
57
- drb (2.1.1)
57
+ drb (2.2.0)
58
58
  ruby2_keywords
59
59
  dry-core (1.0.1)
60
60
  concurrent-ruby (~> 1.0)
@@ -79,7 +79,7 @@ GEM
79
79
  activesupport (>= 3.0, < 8.0)
80
80
  equivalent-xml (0.6.0)
81
81
  nokogiri (>= 1.4.3)
82
- faraday (2.7.11)
82
+ faraday (2.7.12)
83
83
  base64
84
84
  faraday-net_http (>= 2.0, < 3.1)
85
85
  ruby2_keywords (>= 0.0.4)
@@ -96,10 +96,10 @@ GEM
96
96
  language_server-protocol (3.17.0.3)
97
97
  minitest (5.20.0)
98
98
  multi_json (1.15.0)
99
- mutex_m (0.1.2)
100
- nokogiri (1.15.4-x86_64-darwin)
99
+ mutex_m (0.2.0)
100
+ nokogiri (1.15.5-x86_64-darwin)
101
101
  racc (~> 1.4)
102
- nokogiri (1.15.4-x86_64-linux)
102
+ nokogiri (1.15.5-x86_64-linux)
103
103
  racc (~> 1.4)
104
104
  openapi3_parser (0.9.2)
105
105
  commonmarker (~> 0.17)
@@ -111,7 +111,7 @@ GEM
111
111
  racc
112
112
  patience_diff (1.2.0)
113
113
  optimist (~> 3.0)
114
- public_suffix (5.0.3)
114
+ public_suffix (5.0.4)
115
115
  racc (1.7.3)
116
116
  rainbow (3.1.1)
117
117
  rake (13.1.0)
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '13.3.0'
6
+ VERSION = '13.4.0'
7
7
  end
8
8
  end
9
9
  end
@@ -116,10 +116,12 @@ module Dor
116
116
  # @param [String] url the base url of the endpoint the client should connect to (required)
117
117
  # @param [String] token a bearer token for HTTP authentication (required)
118
118
  # @param [Boolean] enable_get_retries retries get requests on errors
119
- def configure(url:, token:, enable_get_retries: false)
119
+ # @param [Logger,nil] logger for logging retry attempts
120
+ def configure(url:, token:, enable_get_retries: true, logger: nil)
120
121
  instance.url = url
121
122
  instance.token = token
122
123
  instance.enable_get_retries = enable_get_retries
124
+ instance.logger = logger
123
125
 
124
126
  # Force connection to be re-established when `.configure` is called
125
127
  instance.connection = nil
@@ -130,21 +132,21 @@ module Dor
130
132
  delegate :background_job_results, :objects, :object, :virtual_objects, :administrative_tags, to: :instance
131
133
  end
132
134
 
133
- attr_writer :url, :token, :connection, :enable_get_retries
135
+ attr_writer :url, :token, :connection, :enable_get_retries, :logger
134
136
 
135
137
  private
136
138
 
137
- attr_reader :token, :enable_get_retries
139
+ attr_reader :token, :enable_get_retries, :logger
138
140
 
139
141
  def url
140
142
  @url || raise(Error, 'url has not yet been configured')
141
143
  end
142
144
 
143
145
  def connection
144
- @connection ||= ConnectionWrapper.new(connection: build_connection, get_connection: build_connection(with_retries: enable_get_retries))
146
+ @connection ||= build_connection(with_retries: enable_get_retries, logger: logger)
145
147
  end
146
148
 
147
- def build_connection(with_retries: false)
149
+ def build_connection(with_retries: false, logger: nil)
148
150
  Faraday.new(url) do |builder|
149
151
  builder.use ErrorFaradayMiddleware
150
152
  builder.use Faraday::Request::UrlEncoded
@@ -157,10 +159,26 @@ module Dor
157
159
  builder.options[:timeout] = 300
158
160
  builder.headers[:user_agent] = user_agent
159
161
  builder.headers[TOKEN_HEADER] = "Bearer #{token}"
160
- builder.request :retry, max: 4, interval: 1, backoff_factor: 2 if with_retries
162
+ builder.request :retry, retry_options(logger) if with_retries
161
163
  end
162
164
  end
163
165
 
166
+ def retry_options(logger) # rubocop:disable Metrics/MethodLength
167
+ {
168
+ max: 4,
169
+ interval: 1,
170
+ backoff_factor: 2,
171
+ exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed],
172
+ methods: %i[get],
173
+ retry_statuses: [503],
174
+ # rubocop:disable Lint/UnusedBlockArgument
175
+ retry_block: lambda { |env:, options:, retry_count:, exception:, will_retry_in:|
176
+ logger&.info("Retry #{retry_count + 1} for #{env.url} due to #{exception.class} (#{exception.message})")
177
+ }
178
+ # rubocop:enable Lint/UnusedBlockArgument
179
+ }
180
+ end
181
+
164
182
  def user_agent
165
183
  "dor-services-client #{Dor::Services::Client::VERSION}"
166
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.3.0
4
+ version: 13.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-11-09 00:00:00.000000000 Z
12
+ date: 2023-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -242,7 +242,6 @@ files:
242
242
  - lib/dor/services/client/async_result.rb
243
243
  - lib/dor/services/client/background_job_results.rb
244
244
  - lib/dor/services/client/collections.rb
245
- - lib/dor/services/client/connection_wrapper.rb
246
245
  - lib/dor/services/client/error_faraday_middleware.rb
247
246
  - lib/dor/services/client/events.rb
248
247
  - lib/dor/services/client/members.rb
@@ -278,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
277
  - !ruby/object:Gem::Version
279
278
  version: '0'
280
279
  requirements: []
281
- rubygems_version: 3.4.19
280
+ rubygems_version: 3.3.7
282
281
  signing_key:
283
282
  specification_version: 4
284
283
  summary: A client for dor-services-app
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dor
4
- module Services
5
- class Client
6
- # Wraps connections to allow GET requests to be retriable.
7
- class ConnectionWrapper
8
- delegate :get, to: :get_connection
9
- delegate :post, :delete, :put, :patch, to: :connection
10
-
11
- def initialize(connection:, get_connection:)
12
- @connection = connection
13
- @get_connection = get_connection
14
- end
15
-
16
- private
17
-
18
- attr_reader :connection, :get_connection
19
- end
20
- end
21
- end
22
- end