dor-services-client 13.2.0 → 13.4.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: c4a4eab86e29b682f95d37da74618794a84bd08475e704449f245dc41ecd84e1
4
- data.tar.gz: 6960751d7cf833f681426c41ced9beb4900af12f126f37a7028d639ada65d37a
3
+ metadata.gz: 9fc7a961142bc17fc963a387e6ee067b7c682eebebe455b26a7fde3f1d77ab13
4
+ data.tar.gz: 68c9d80398a759ae79b010d9391ed5b21f3478db4d9a80868f497ecdeabffa73
5
5
  SHA512:
6
- metadata.gz: 0cc64aa9f1e20e6c79bd8e48b8576b079f9acfab2d1e859beb85e89c66e05ea353730709daba949429186e29f28bbbd67d3d4b5c0bd8b1284f15959f496f12d9
7
- data.tar.gz: d1b32c6f1bb79c8fbb07004c6574daa255728c4a09d57a7d68290bdeea52b15b0d1ad248c7662aed3fbd7a2ab4b53bef771d5d03f7bc7b65b748040d32d83e90
6
+ metadata.gz: 9c4d4996966dd96f18c09ed4e5d59183e7400b2f794b113df3c722d451c61aec1e4dfecca6b4ae80eb23579b2208b9eabac3b38daa5c0f6b9f6c46cf40fb05df
7
+ data.tar.gz: 99ab68808e096af0d98046f79e461049bc1d7447a8c939deee07af50ceb68d20c247b8aadbd2b48c26aa4fdd27fddd10f3bb29e79c3fb23bedea0e2589ffa83f
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (13.2.0)
4
+ dor-services-client (13.4.0)
5
5
  activesupport (>= 4.2, < 8)
6
- cocina-models (~> 0.92.0)
6
+ cocina-models (~> 0.93.0)
7
7
  deprecation
8
8
  faraday (~> 2.0)
9
9
  faraday-retry
@@ -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,10 +26,10 @@ 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
- cocina-models (0.92.0)
32
+ cocina-models (0.93.0)
33
33
  activesupport
34
34
  deprecation
35
35
  dry-struct (~> 1.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,8 +111,8 @@ GEM
111
111
  racc
112
112
  patience_diff (1.2.0)
113
113
  optimist (~> 3.0)
114
- public_suffix (5.0.3)
115
- racc (1.7.1)
114
+ public_suffix (5.0.4)
115
+ racc (1.7.3)
116
116
  rainbow (3.1.1)
117
117
  rake (13.1.0)
118
118
  regexp_parser (2.8.2)
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 3.0', '< 4'
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 4.2', '< 8'
28
- spec.add_dependency 'cocina-models', '~> 0.92.0'
28
+ spec.add_dependency 'cocina-models', '~> 0.93.0'
29
29
  spec.add_dependency 'deprecation', '>= 0'
30
30
  spec.add_dependency 'faraday', '~> 2.0'
31
31
  spec.add_dependency 'faraday-retry'
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '13.2.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.2.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-03 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
@@ -37,14 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.92.0
40
+ version: 0.93.0
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.92.0
47
+ version: 0.93.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -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