wayfarer 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/docs/guides/error_handling.md +23 -1
- data/docs/reference/configuration_keys.md +1 -0
- data/lib/wayfarer/config/networking.rb +3 -0
- data/lib/wayfarer/networking/context.rb +1 -1
- data/lib/wayfarer.rb +1 -1
- data/spec/networking/context_spec.rb +17 -0
- data/wayfarer.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b5aceb6e67a298f9ddc3bffecf24446b2e95850e2bfe31f0d245fbb8a4e17f0
|
4
|
+
data.tar.gz: db7323a6cb7942319478753d3060b54cdc7551c3ac6fb0c32bf49015d6f29c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 016a9d535cf7a3c02afc1bb2503d701328cb6ac55e8c8bdfdeda782c6c8d2eab8528ef30c1b05e4241b8f439f98617865b7d00ff7fd6b49683d288d431e37936
|
7
|
+
data.tar.gz: 748d79ed7028e114dc2aff3cb1d31b4163bc7ff289ea9f20f78bec4c5941622ecf40e58330e7e5c678884f37cbb800b8bd2acb8aca106916e8daccc510567e85
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* Wayfarer never swallows exceptions.
|
6
6
|
* Jobs with unhandled exceptions are not retried.
|
7
7
|
|
8
|
-
## Retrying
|
8
|
+
## Retrying or discarding failing jobs
|
9
9
|
|
10
10
|
Wayfarer relies on [Active Job's two error handling facilities](https://guides.rubyonrails.org/active_job_basics.html#exceptions).
|
11
11
|
|
@@ -16,6 +16,8 @@ Wayfarer relies on [Active Job's two error handling facilities](https://guides.r
|
|
16
16
|
retry_on MyError, attempts: 3 do |job, error|
|
17
17
|
# This block runs once all 3 attempts have failed
|
18
18
|
# (1 initial attempt + 2 retries)
|
19
|
+
|
20
|
+
raise error
|
19
21
|
end
|
20
22
|
end
|
21
23
|
```
|
@@ -26,6 +28,26 @@ Wayfarer relies on [Active Job's two error handling facilities](https://guides.r
|
|
26
28
|
class DummyJob < Wayfarer::Base
|
27
29
|
discard_on MyError do |job, error|
|
28
30
|
# This block runs once and buries the job
|
31
|
+
|
32
|
+
raise error
|
29
33
|
end
|
30
34
|
end
|
31
35
|
```
|
36
|
+
|
37
|
+
!!! attention "Always re-raise errors"
|
38
|
+
|
39
|
+
You should always re-raise errors from `retry_on` and `discard_on` blocks,
|
40
|
+
otherwise jobs will not get retried!
|
41
|
+
|
42
|
+
## Renewing agents on certain errors
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Wayfarer.config.network.renew_on = [MyError]
|
46
|
+
```
|
47
|
+
|
48
|
+
For example, if you use the Capybara
|
49
|
+
[Cuprite](https://github.com/rubycdp/cuprite) driver:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Wayfarer.config.network.renew_on = [Ferrum::DeadBrowserError]
|
53
|
+
```
|
@@ -13,6 +13,7 @@ hide:
|
|
13
13
|
| `network.pool_size` | `WAYFARER_NETWORK_POOL_SIZE` | How many user agents to spawn. | 1 | Integers |
|
14
14
|
| `network.pool_timeout` | `WAYFARER_NETWORK_POOL_TIMEOUT` | How long jobs may use an agent in seconds. | 10 | Integers |
|
15
15
|
| `network.http_headers` | `WAYFARER_NETWORK_HTTP_HEADERS` | HTTP headers to append to requests. | `{}` | Hashes |
|
16
|
+
| `network.renew_on` | | Exception classes to renew agents on. | `[]` | Classes |
|
16
17
|
|
17
18
|
## `Wayfarer.config.ferrum`
|
18
19
|
|
data/lib/wayfarer.rb
CHANGED
@@ -45,6 +45,23 @@ describe Wayfarer::Networking::Context do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
context "with configured renewing exception raised" do
|
49
|
+
let(:other_error) { Class.new(StandardError) }
|
50
|
+
|
51
|
+
before do
|
52
|
+
Wayfarer.config.network.renew_on = [other_error]
|
53
|
+
allow(strategy).to receive(:fetch).and_raise(other_error)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "renews and reraises" do
|
57
|
+
expect(context).to receive(:renew)
|
58
|
+
|
59
|
+
expect {
|
60
|
+
context.fetch(url)
|
61
|
+
}.to raise_error(other_error)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
48
65
|
context "with non-renewing exception raised" do
|
49
66
|
before do
|
50
67
|
allow(strategy).to receive(:fetch).and_raise(StandardError)
|
data/wayfarer.gemspec
CHANGED