pact 1.23.0 → 1.24.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
  SHA1:
3
- metadata.gz: 2f08c3f242d549648001e7294df45094bf80bdfe
4
- data.tar.gz: 84c7976f630dcaee652d7c10eb8d6a2bcd9c64a4
3
+ metadata.gz: 552d608df849af7001c18df8b94463ec9e9da3bf
4
+ data.tar.gz: 9a3c2bff39b66747e85af6056ce70c14b1d717ae
5
5
  SHA512:
6
- metadata.gz: d844246c78be90a05be79a69901b9d57c27d5f31b6ea4b2ef79160e2b9524b7e56788ba3b5308815e0108dec02c1f977be528af6f69f1f4c3c5debfda60277fa
7
- data.tar.gz: 508f3d6b351a05dc480122ddca8c4ea86fc7c4169d58e309649ae0e39a07bf7e8ac0960d8bbd12c381cba25bf8fdd4ed5ad2642b2286210af97ce8033e4beff2
6
+ metadata.gz: 74b503a7555d1a08fd19c179379e4eb2c809dcf4acb0b644c978f25468771d55766c1b2ecdcb285c928690644b905017518d6002798eeb73d91ee2ae51104665
7
+ data.tar.gz: c5b3f0d850f25e6641dcc84a053b79798f56e79f95dc2ec2825f9f4dc5b847f5acd54aaaa5b2c413b216c08e0e8f292466aac57e1f0cea9b8effa9c0fdd32577
@@ -1,3 +1,12 @@
1
+ <a name="v1.24.0"></a>
2
+ ### v1.24.0 (2018-04-13)
3
+
4
+
5
+ #### Features
6
+
7
+ * Add retries to verification publishing ([6620165](/../../commit/6620165))
8
+
9
+
1
10
  <a name="v1.23.0"></a>
2
11
  ### v1.23.0 (2018-04-16)
3
12
 
@@ -1,17 +1,15 @@
1
1
  require 'json'
2
2
  require 'pact/errors'
3
+ require 'pact/retry'
3
4
 
4
5
  # TODO move this to the pact broker client
5
- # TODO retries
6
6
 
7
7
  module Pact
8
8
  module Provider
9
9
  module VerificationResults
10
-
11
10
  class PublicationError < Pact::Error; end
12
11
 
13
12
  class Publish
14
-
15
13
  def self.call pact_source, verification_result
16
14
  new(pact_source, verification_result).call
17
15
  end
@@ -75,8 +73,10 @@ module Pact
75
73
  response = nil
76
74
  begin
77
75
  options = {:use_ssl => uri.scheme == 'https'}
78
- response = Net::HTTP.start(uri.host, uri.port, options) do |http|
79
- http.request request
76
+ Retry.until_true do
77
+ response = Net::HTTP.start(uri.host, uri.port, options) do |http|
78
+ http.request request
79
+ end
80
80
  end
81
81
  rescue StandardError => e
82
82
  error_message = "Failed to tag provider version due to: #{e.class} #{e.message}"
@@ -95,16 +95,16 @@ module Pact
95
95
  response = nil
96
96
  begin
97
97
  options = {:use_ssl => uri.scheme == 'https'}
98
- response = Net::HTTP.start(uri.host, uri.port, options) do |http|
99
- http.request request
98
+ Retry.until_true do
99
+ response = Net::HTTP.start(uri.host, uri.port, options) do |http|
100
+ http.request request
101
+ end
100
102
  end
101
103
  rescue StandardError => e
102
104
  error_message = "Failed to publish verification results due to: #{e.class} #{e.message}"
103
105
  raise PublicationError.new(error_message)
104
106
  end
105
107
 
106
-
107
-
108
108
  if response.code.start_with?("2")
109
109
  new_resource_url = JSON.parse(response.body)['_links']['self']['href']
110
110
  Pact.configuration.output_stream.puts "INFO: Verification results published to #{new_resource_url}"
@@ -0,0 +1,35 @@
1
+ module Pact
2
+ class Retry
3
+ class RescuableError
4
+ UNRESCUEABLE = [Pact::Error]
5
+
6
+ def self.===(e)
7
+ case e
8
+ when *UNRESCUEABLE then
9
+ false
10
+ else
11
+ true
12
+ end
13
+ end
14
+ end
15
+
16
+ def self.until_true options = {}
17
+ max_tries = options.fetch(:times, 3)
18
+ tries = 0
19
+ while true
20
+ begin
21
+ return yield
22
+ rescue RescuableError => e
23
+ tries += 1
24
+ $stderr.puts "Error making request - #{e.class} #{e.message} #{e.backtrace.find {|l| l.include?('pact_provider')}}, attempt #{tries} of #{max_tries}"
25
+ raise e if max_tries == tries
26
+ sleep options
27
+ end
28
+ end
29
+ end
30
+
31
+ def self.sleep options
32
+ Kernel.sleep options.fetch(:sleep, 5)
33
+ end
34
+ end
35
+ end
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.23.0"
3
+ VERSION = "1.24.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-04-15 00:00:00.000000000 Z
15
+ date: 2018-04-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -374,6 +374,7 @@ files:
374
374
  - lib/pact/provider/verification_results/publish_all.rb
375
375
  - lib/pact/provider/verification_results/verification_result.rb
376
376
  - lib/pact/provider/world.rb
377
+ - lib/pact/retry.rb
377
378
  - lib/pact/tasks.rb
378
379
  - lib/pact/tasks/task_helper.rb
379
380
  - lib/pact/tasks/verification_task.rb