philiprehberger-retry_queue 0.5.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -0
- data/lib/philiprehberger/retry_queue/result.rb +12 -0
- data/lib/philiprehberger/retry_queue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96d4078aaeb7a082f0b36dc2121077882c4ae88d5acba91acdf668b2de76d42c
|
|
4
|
+
data.tar.gz: 92e49204be845308e033260af04fa8aa1d40fa328ab14a7cb2c31a5e4c54cbb7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a43f5db92ac6e907a95b51b066852a55f9203f88f44600649dd12bfd6b93568dea33c12722869dc951b3f2927f70adca69a68a6cc423bdd4ac2463d815259319
|
|
7
|
+
data.tar.gz: 03466f8aeb298b0d4ff161b43a913967662ed59d2add9e5a9ff6cdbc7b027a849a556d370e9edd41badc3e18b409f05d43079f5b3ab28e08e0dc98839525cc4d
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-05-07
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Result#failure_rate` — counterpart to `#success_rate`, returns the ratio of failed items to total. Returns `0.0` for empty batches.
|
|
14
|
+
|
|
10
15
|
## [0.5.0] - 2026-04-23
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -126,8 +126,13 @@ stats = result.stats
|
|
|
126
126
|
```ruby
|
|
127
127
|
result = Philiprehberger::RetryQueue.process(items, max_retries: 3) { |item| call(item) }
|
|
128
128
|
result.success_rate # => 0.92
|
|
129
|
+
result.failure_rate # => 0.08
|
|
129
130
|
```
|
|
130
131
|
|
|
132
|
+
`Result#failure_rate` is the counterpart to `#success_rate` and pairs naturally with
|
|
133
|
+
it — for any non-empty Result, `success_rate + failure_rate` sums to `1.0`. Empty
|
|
134
|
+
batches return `0.0` for both.
|
|
135
|
+
|
|
131
136
|
## API
|
|
132
137
|
|
|
133
138
|
| Method | Description |
|
|
@@ -140,6 +145,7 @@ result.success_rate # => 0.92
|
|
|
140
145
|
| `Result#failed` | Array of hashes with `:item`, `:error`, `:attempts` |
|
|
141
146
|
| `Result#stats` | Hash with `:total`, `:succeeded`, `:failed`, `:success_rate`, `:elapsed` |
|
|
142
147
|
| `Result#success_rate` | Float in `[0.0, 1.0]`; ratio of succeeded to total items (`0.0` for empty batches) |
|
|
148
|
+
| `Result#failure_rate` | Ratio of failed items to total (0.0..1.0); pairs with success_rate |
|
|
143
149
|
| `Result#empty?` | `true` when `stats[:total]` is 0 |
|
|
144
150
|
| `Result#size` | Returns `stats[:total]` (succeeded + failed count) |
|
|
145
151
|
| `Result#reprocess_failed { \|item, error\| }` | Reprocess failed items, returns a new Result |
|
|
@@ -59,6 +59,18 @@ module Philiprehberger
|
|
|
59
59
|
@succeeded.size.to_f / total
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
# Ratio of failed items to total processed items.
|
|
63
|
+
#
|
|
64
|
+
# Returns 0.0 for an empty batch to avoid ZeroDivisionError.
|
|
65
|
+
#
|
|
66
|
+
# @return [Float] ratio in the range [0.0, 1.0]
|
|
67
|
+
def failure_rate
|
|
68
|
+
total = @succeeded.size + @failed.size
|
|
69
|
+
return 0.0 if total.zero?
|
|
70
|
+
|
|
71
|
+
@failed.size.to_f / total
|
|
72
|
+
end
|
|
73
|
+
|
|
62
74
|
# Reprocess failed items by yielding each item and its last error to the block.
|
|
63
75
|
# Returns a new Result with the reprocessing outcomes.
|
|
64
76
|
#
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-retry_queue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Processes collections of items with configurable per-item retry logic,
|
|
14
14
|
exponential backoff, and dead letter collection for failed items. Returns detailed
|