dor-services-client 13.3.0 → 14.0.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: 1b076fd6caac43d4e331257b695ad6bef33baa1c9908f29c32523ed2730355bc
4
+ data.tar.gz: 6f61305cd1386b271e285dd9257e82e4d04849abf95f4ca42a76298ed41e2a8d
5
5
  SHA512:
6
- metadata.gz: 9cf0562b1d1350a1aeeba117fed6ff4d1e03ca774afc937dc9e0ac1d9f7b833366529c38130af1584cc97837b616dd09cad967f872928e102328a0c8e811041e
7
- data.tar.gz: 8de967354fb73c2a12b627be58f1caa785ce3e4b3349293d43cae8012606e3b914a40cd3d3126cbea7a395c8171b89f31263193ecb7f8999c036daa3e4ad32ba
6
+ metadata.gz: d2faa7000458238ffc537d0ae75279bcbd1f1e9130987c4ac62eb30c1cacc137ad516ebc61847e21f48e1e8b99ab50ac74edd61a9a85b7d48d2861b4a58d4246
7
+ data.tar.gz: f3f5f5c03b9773353303876dd9357996c23c9dc99a0d4eeca1d9f3b29e5410debf77558e9d0cf000230316e6eca595e33be40c78cca3fae36ea25ed87f7e7e4b
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 (14.0.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)
@@ -22,14 +22,14 @@ GEM
22
22
  minitest (>= 5.1)
23
23
  mutex_m
24
24
  tzinfo (~> 2.0)
25
- addressable (2.8.5)
25
+ addressable (2.8.6)
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)
30
- bigdecimal (3.1.4)
29
+ base64 (0.2.0)
30
+ bigdecimal (3.1.5)
31
31
  byebug (11.1.3)
32
- cocina-models (0.93.0)
32
+ cocina-models (0.93.1)
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)
@@ -69,7 +69,8 @@ GEM
69
69
  dry-types (>= 1.7, < 2)
70
70
  ice_nine (~> 0.11)
71
71
  zeitwerk (~> 2.6)
72
- dry-types (1.7.1)
72
+ dry-types (1.7.2)
73
+ bigdecimal (~> 3.0)
73
74
  concurrent-ruby (~> 1.0)
74
75
  dry-core (~> 1.0)
75
76
  dry-inflector (~> 1.0)
@@ -79,43 +80,43 @@ GEM
79
80
  activesupport (>= 3.0, < 8.0)
80
81
  equivalent-xml (0.6.0)
81
82
  nokogiri (>= 1.4.3)
82
- faraday (2.7.11)
83
+ faraday (2.8.1)
83
84
  base64
84
85
  faraday-net_http (>= 2.0, < 3.1)
85
86
  ruby2_keywords (>= 0.0.4)
86
87
  faraday-net_http (3.0.2)
87
88
  faraday-retry (2.2.0)
88
89
  faraday (~> 2.0)
89
- hashdiff (1.0.1)
90
+ hashdiff (1.1.0)
90
91
  i18n (1.14.1)
91
92
  concurrent-ruby (~> 1.0)
92
93
  ice_nine (0.11.2)
93
- json (2.6.3)
94
+ json (2.7.1)
94
95
  jsonpath (1.1.5)
95
96
  multi_json
96
97
  language_server-protocol (3.17.0.3)
97
98
  minitest (5.20.0)
98
99
  multi_json (1.15.0)
99
- mutex_m (0.1.2)
100
- nokogiri (1.15.4-x86_64-darwin)
100
+ mutex_m (0.2.0)
101
+ nokogiri (1.16.0-x86_64-darwin)
101
102
  racc (~> 1.4)
102
- nokogiri (1.15.4-x86_64-linux)
103
+ nokogiri (1.16.0-x86_64-linux)
103
104
  racc (~> 1.4)
104
105
  openapi3_parser (0.9.2)
105
106
  commonmarker (~> 0.17)
106
107
  openapi_parser (1.0.0)
107
108
  optimist (3.1.0)
108
- parallel (1.23.0)
109
- parser (3.2.2.4)
109
+ parallel (1.24.0)
110
+ parser (3.3.0.2)
110
111
  ast (~> 2.4.1)
111
112
  racc
112
113
  patience_diff (1.2.0)
113
114
  optimist (~> 3.0)
114
- public_suffix (5.0.3)
115
+ public_suffix (5.0.4)
115
116
  racc (1.7.3)
116
117
  rainbow (3.1.1)
117
118
  rake (13.1.0)
118
- regexp_parser (2.8.2)
119
+ regexp_parser (2.8.3)
119
120
  rexml (3.2.6)
120
121
  rspec (3.12.0)
121
122
  rspec-core (~> 3.12.0)
@@ -132,7 +133,7 @@ GEM
132
133
  rspec-support (3.12.1)
133
134
  rss (0.3.0)
134
135
  rexml
135
- rubocop (1.57.2)
136
+ rubocop (1.59.0)
136
137
  json (~> 2.3)
137
138
  language_server-protocol (>= 3.17.0)
138
139
  parallel (~> 1.10)
@@ -140,16 +141,16 @@ GEM
140
141
  rainbow (>= 2.2.2, < 4.0)
141
142
  regexp_parser (>= 1.8, < 3.0)
142
143
  rexml (>= 3.2.5, < 4.0)
143
- rubocop-ast (>= 1.28.1, < 2.0)
144
+ rubocop-ast (>= 1.30.0, < 2.0)
144
145
  ruby-progressbar (~> 1.7)
145
146
  unicode-display_width (>= 2.4.0, < 3.0)
146
147
  rubocop-ast (1.30.0)
147
148
  parser (>= 3.2.1.0)
148
- rubocop-capybara (2.19.0)
149
+ rubocop-capybara (2.20.0)
149
150
  rubocop (~> 1.41)
150
- rubocop-factory_bot (2.24.0)
151
- rubocop (~> 1.33)
152
- rubocop-rspec (2.25.0)
151
+ rubocop-factory_bot (2.25.1)
152
+ rubocop (~> 1.41)
153
+ rubocop-rspec (2.26.1)
153
154
  rubocop (~> 1.40)
154
155
  rubocop-capybara (~> 2.17)
155
156
  rubocop-factory_bot (~> 2.22)
@@ -5,7 +5,7 @@ module Dor
5
5
  class Client
6
6
  # API call that queries the members of a collection.
7
7
  class Members < VersionedService
8
- Member = Struct.new(:externalIdentifier, :type, keyword_init: true)
8
+ Member = Struct.new(:externalIdentifier, :version, keyword_init: true)
9
9
 
10
10
  # @param object_identifier [String] the pid for the object
11
11
  def initialize(connection:, version:, object_identifier:)
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '13.3.0'
6
+ VERSION = '14.0.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: 14.0.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: 2024-01-10 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