purl_fetcher-client 3.1.0 → 3.2.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/lib/purl_fetcher/client/publish.rb +5 -3
- data/lib/purl_fetcher/client/version.rb +1 -1
- data/lib/purl_fetcher/client.rb +15 -3
- data/purl_fetcher-client.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4a427ea0fc7172db70ff3eda2c7a75af5bac22243937d24373e70b43c34f994
|
|
4
|
+
data.tar.gz: 8d1fe470e1594286d8d6913c1391e64d66b984151a0241557b169d52c950910f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6d8a4381128db431250ac19797a7f5e4d20570e6b6c7eb2bb9e05332e61c105627e5f4bc066a303f06bbf8c3ebb5c0410740d711da2def59e5454decd09ab42
|
|
7
|
+
data.tar.gz: 9646c456a2aabe7692bad7973612d27a954c120ed1d86066cb8af7995452158581ed0a226cbaf0842ddc23ec9a11b7e6da8125a49084218de71faed6d7d4de0f
|
|
@@ -13,23 +13,25 @@ module PurlFetcher
|
|
|
13
13
|
# @param [String] version the version of the item
|
|
14
14
|
# @param [DateTime] version_date the version date
|
|
15
15
|
# @param [Boolean] must_version whether the item must be versioned
|
|
16
|
-
|
|
16
|
+
# @param [Boolean] retriable whether to retry on failure
|
|
17
|
+
def initialize(cocina:, file_uploads:, version:, version_date:, must_version:, retriable: true)
|
|
17
18
|
@cocina = cocina
|
|
18
19
|
@file_uploads = file_uploads
|
|
19
20
|
@version = version
|
|
20
21
|
@version_date = version_date
|
|
21
22
|
@must_version = must_version
|
|
23
|
+
@retriable = retriable
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def publish
|
|
25
27
|
logger.debug("Starting a publish request for: #{druid}")
|
|
26
|
-
client.put(path:, body:)
|
|
28
|
+
client.put(path:, body:, retriable:)
|
|
27
29
|
logger.debug("Publish request complete")
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
private
|
|
31
33
|
|
|
32
|
-
attr_reader :cocina, :file_uploads, :version, :version_date, :must_version
|
|
34
|
+
attr_reader :cocina, :file_uploads, :version, :version_date, :must_version, :retriable
|
|
33
35
|
|
|
34
36
|
def druid
|
|
35
37
|
cocina.externalIdentifier
|
data/lib/purl_fetcher/client.rb
CHANGED
|
@@ -76,8 +76,9 @@ module PurlFetcher
|
|
|
76
76
|
# @param path [String] the path for the API request
|
|
77
77
|
# @param body [String] the body of the POST request
|
|
78
78
|
# @param headers [Hash] extra headers to add to the SDR API request
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
# @param retriable [Boolean] whether to retry on failure
|
|
80
|
+
def put(path:, body: nil, headers: {}, retriable: false)
|
|
81
|
+
response = connection(retriable:).put(path) do |request|
|
|
81
82
|
request.body = body if body
|
|
82
83
|
request.headers = default_headers.merge(headers)
|
|
83
84
|
end
|
|
@@ -91,12 +92,23 @@ module PurlFetcher
|
|
|
91
92
|
|
|
92
93
|
Config = Data.define(:url, :logger, :token)
|
|
93
94
|
|
|
94
|
-
def connection
|
|
95
|
+
def connection(retriable: false)
|
|
95
96
|
Faraday.new(
|
|
96
97
|
url: config.url,
|
|
97
98
|
headers: default_headers,
|
|
98
99
|
request: default_request_options
|
|
99
100
|
) do |conn|
|
|
101
|
+
if retriable
|
|
102
|
+
conn.request :retry,
|
|
103
|
+
max: 3,
|
|
104
|
+
interval: 15,
|
|
105
|
+
backoff_factor: 2,
|
|
106
|
+
exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS,
|
|
107
|
+
retry_statuses: [ 500 ],
|
|
108
|
+
retry_block: lambda { |env:, retry_count:, exception:, **|
|
|
109
|
+
config.logger.warn("Retrying request to #{env.url} (#{retry_count} retries): #{exception&.message}")
|
|
110
|
+
}
|
|
111
|
+
end
|
|
100
112
|
conn.response :json
|
|
101
113
|
end
|
|
102
114
|
end
|
data/purl_fetcher-client.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: purl_fetcher-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Beer
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '2.1'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: faraday-retry
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '2.4'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.4'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: bundler
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
162
|
- !ruby/object:Gem::Version
|
|
149
163
|
version: '0'
|
|
150
164
|
requirements: []
|
|
151
|
-
rubygems_version:
|
|
165
|
+
rubygems_version: 4.0.6
|
|
152
166
|
specification_version: 4
|
|
153
167
|
summary: Traject-compatible reader implementation for streaming data from purl-fetcher
|
|
154
168
|
test_files: []
|