dor-services-client 3.7.0 → 3.8.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: a3579f137bb76a9db9abb8b701de338b7fd4d6190d2aa36337c51141d8611db6
4
- data.tar.gz: 8096f0878f77f2c79e477ab4c34e7d8cd47ac1fffb1b17b2be887ee094447ea7
3
+ metadata.gz: 17d1bc1362286691b1f977cad23f8a4055fdd12009b23fb407c59813d302cbc3
4
+ data.tar.gz: a9279fc138723d1d9e6c9d3be6ef5de0736cbe06c5b03de72270b079e1336d29
5
5
  SHA512:
6
- metadata.gz: 044544aa4d1b55cbec9eb6ff17a3f92c3ee8e1b3326c0ab892bbfe143e20d6fb5e26b280a414028f7b79d945ce46f05b265370c949e42b1cda2afa0465963cf1
7
- data.tar.gz: 3d5c76a3c79318e8c5eacb24f8d82a1ecc97df50513491637d1644c1f2ed73c83d187826e7af52c4f5f72fc7f34c11f82216fd7687d8933a8956b71ccaac40e2
6
+ metadata.gz: 40fff715eb9581abefd027fbd29bb92b955cd6d15b77c525966313f35feccd72f7f4cf8443114938e952d74aba57811bc9ada622d5cd6f17dd90180e1ab146d2
7
+ data.tar.gz: '0483086f12869253fbeef14715703ed1c23ac74f8d068bd23a96c80f720a1188d0029f9f6c5d39b15d9da20a789d536da5bd468fcb35de608ae2fa779e6f4a54'
@@ -14,11 +14,16 @@ module Dor
14
14
  @url = url
15
15
  end
16
16
 
17
- # @param [Integer] seconds_between_requests (3) how many seconds between polling requests
17
+ # Polls using exponential backoff, so as not to overrwhelm the server.
18
+ # @param [Float] seconds_between_requests (3.0) initially, how many seconds between polling requests
18
19
  # @param [Integer] timeout_in_seconds (180) timeout after this many seconds
20
+ # @param [Float] backoff_factor (2.0) how quickly to backoff. This should be > 1.0 and probably ought to be <= 2.0
19
21
  # @return true if successful false if unsuccessful.
20
- def wait_until_complete(seconds_between_requests: 3, timeout_in_seconds: 180)
21
- poll_until_complete(seconds_between_requests, timeout_in_seconds)
22
+ def wait_until_complete(seconds_between_requests: 3.0,
23
+ timeout_in_seconds: 180,
24
+ backoff_factor: 2.0,
25
+ max_seconds_between_requests: 60)
26
+ poll_until_complete(seconds_between_requests, timeout_in_seconds, backoff_factor, max_seconds_between_requests)
22
27
  errors.nil?
23
28
  end
24
29
 
@@ -34,12 +39,15 @@ module Dor
34
39
 
35
40
  private
36
41
 
37
- def poll_until_complete(seconds_between_requests, timeout_in_seconds)
42
+ def poll_until_complete(seconds_between_requests, timeout_in_seconds, backoff_factor, max_seconds_between_requests)
43
+ interval = seconds_between_requests
38
44
  Timeout.timeout(timeout_in_seconds) do
39
45
  loop do
40
46
  break if complete?
41
47
 
42
- sleep(seconds_between_requests)
48
+ sleep(interval)
49
+ # Exponential backoff, limited to max_seconds_between_requests
50
+ interval = [interval * backoff_factor, max_seconds_between_requests].min
43
51
  end
44
52
  end
45
53
  rescue Timeout::Error
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: tru
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Dor
4
4
  module Services
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: tru
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Dor
4
4
  module Services
@@ -70,12 +70,10 @@ module Dor
70
70
  # @param [String] workflow ('accessionWF') which workflow to callback to.
71
71
  # @return [boolean] true on success
72
72
  def publish(workflow: nil)
73
- unless workflow
74
- workflow = 'accessionWF'
75
- Deprecation.warn(self, 'calling publish without passing a workflow is deprecated and will be removed in the next major version')
76
- end
73
+ publish_path = "#{object_path}/publish"
74
+ publish_path = "#{publish_path}?workflow=#{workflow}" if workflow
77
75
  resp = connection.post do |req|
78
- req.url "#{object_path}/publish?workflow=#{workflow}"
76
+ req.url publish_path
79
77
  end
80
78
  return resp.headers['Location'] if resp.success?
81
79
 
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '3.7.0'
6
+ VERSION = '3.8.0'
7
7
  end
8
8
  end
9
9
  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: 3.7.0
4
+ version: 3.8.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: 2019-11-04 00:00:00.000000000 Z
12
+ date: 2019-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport