txgh-queue 1.0.2 → 1.1.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: ec976eef014c4582083125e7c2b696d2c213ce5e
4
- data.tar.gz: 6c79801123d2e94bae20d8cbea886918666b4f13
3
+ metadata.gz: 94ea310fa6024cfec2a3633a3c490ee43c62a90a
4
+ data.tar.gz: 9488d256485ccaa83187f46fbe92151050fcae19
5
5
  SHA512:
6
- metadata.gz: 7dcde23ddcd13037a172315976fcce4f980f513121849a8f2c42a207a031323b2dc3682f2899f022bde4c4c2c124517e468165044f42d7431382c04504cc197c
7
- data.tar.gz: 1cb352f91b36edf958f7afccae397b615946fc5951a9e23f0ffa9325c4e826ac954daf920f1b8397c59401f6010430bdebe35fa1ab8190cdfa80036d3b96e1d7
6
+ metadata.gz: 370826c97e654c5a9f7b760d9f83144a5ff986cb00d40a3dd872eaaa3f670b96275148cd5d2e622b05bca085373c8a7478aac0c4da790089387c4a04b85ab95c
7
+ data.tar.gz: 69cc8497763d439b3256dd00e91427ec4618f827290f18264c307930766d422e38882ddad2d4037fdf458ad1bab4e375606a1679bb70ba10d774470a39754903
@@ -0,0 +1,26 @@
1
+ require 'txgh'
2
+ require 'faraday'
3
+ require 'net/protocol'
4
+
5
+ module TxghQueue
6
+ module ErrorHandlers
7
+ class NetworkErrors
8
+ ERROR_CLASSES = {
9
+ Faraday::ConnectionFailed => Status.retry_with_delay,
10
+ Faraday::TimeoutError => Status.retry_with_delay,
11
+ Net::OpenTimeout => Status.retry_with_delay,
12
+ Net::ReadTimeout => Status.retry_with_delay
13
+ }
14
+
15
+ class << self
16
+ def can_handle?(error_or_response)
17
+ ERROR_CLASSES.any? { |klass, _| error_or_response.class <= klass }
18
+ end
19
+
20
+ def status_for(error)
21
+ ERROR_CLASSES[error.class]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,7 @@
1
1
  module TxghQueue
2
2
  module ErrorHandlers
3
3
  autoload :Github, 'txgh-queue/error_handlers/github'
4
+ autoload :NetworkErrors, 'txgh-queue/error_handlers/network_errors'
4
5
  autoload :ServerResponse, 'txgh-queue/error_handlers/server_response'
5
6
  autoload :StandardErrors, 'txgh-queue/error_handlers/standard_errors'
6
7
  autoload :Transifex, 'txgh-queue/error_handlers/transifex'
@@ -13,7 +13,8 @@ module TxghQueue
13
13
  ErrorHandlers::Github,
14
14
  ErrorHandlers::Transifex,
15
15
  ErrorHandlers::TxghErrors,
16
- ErrorHandlers::StandardErrors
16
+ ErrorHandlers::StandardErrors,
17
+ ErrorHandlers::NetworkErrors
17
18
  ]
18
19
 
19
20
  class << self
@@ -1,3 +1,3 @@
1
1
  module TxghQueue
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ include TxghQueue
4
+
5
+ describe ErrorHandlers::NetworkErrors do
6
+ describe '.can_handle?' do
7
+ it 'can reply to faraday connection errors' do
8
+ error = Faraday::ConnectionFailed.new(StandardError.new)
9
+ expect(described_class.can_handle?(error)).to eq(true)
10
+ end
11
+
12
+ it 'can reply to faraday timeout errors' do
13
+ error = Faraday::TimeoutError.new
14
+ expect(described_class.can_handle?(error)).to eq(true)
15
+ end
16
+
17
+ it 'can reply to ruby open timeout errors' do
18
+ error = Net::OpenTimeout.new
19
+ expect(described_class.can_handle?(error)).to eq(true)
20
+ end
21
+
22
+ it 'can reply to ruby read timeout errors' do
23
+ error = Net::ReadTimeout.new
24
+ expect(described_class.can_handle?(error)).to eq(true)
25
+ end
26
+ end
27
+
28
+ describe '.status_for' do
29
+ it 'retries with delay on faraday connection error' do
30
+ error = Faraday::ConnectionFailed.new(StandardError.new)
31
+ expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
32
+ end
33
+
34
+ it 'retries with delay on faraday timeout error' do
35
+ error = Faraday::TimeoutError.new
36
+ expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
37
+ end
38
+
39
+ it 'retries with delay on ruby open timeout error' do
40
+ error = Net::OpenTimeout.new
41
+ expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
42
+ end
43
+
44
+ it 'retries with delay on ruby read timeout error' do
45
+ error = Net::ReadTimeout.new
46
+ expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txgh-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -103,6 +103,7 @@ files:
103
103
  - lib/txgh-queue/config.rb
104
104
  - lib/txgh-queue/error_handlers.rb
105
105
  - lib/txgh-queue/error_handlers/github.rb
106
+ - lib/txgh-queue/error_handlers/network_errors.rb
106
107
  - lib/txgh-queue/error_handlers/server_response.rb
107
108
  - lib/txgh-queue/error_handlers/standard_errors.rb
108
109
  - lib/txgh-queue/error_handlers/transifex.rb
@@ -130,6 +131,7 @@ files:
130
131
  - spec/backends_spec.rb
131
132
  - spec/config_spec.rb
132
133
  - spec/error_handlers/github_spec.rb
134
+ - spec/error_handlers/network_errors_spec.rb
133
135
  - spec/error_handlers/server_response_spec.rb
134
136
  - spec/error_handlers/standard_errors_spec.rb
135
137
  - spec/error_handlers/transifex_spec.rb