philiprehberger-retry_queue 0.3.0 → 0.4.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 +8 -0
- data/lib/philiprehberger/retry_queue/result.rb +13 -1
- 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: 933efd4881279b847d651e774a565205b246ae3859b624cc2715373549664d58
|
|
4
|
+
data.tar.gz: c24e1b713702a4775248ca23b4e88d08dab9b2e077c0f78ca866ad08ec50a629
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d17e2e333cbf2cf723ea0bbb2519186a24487fc5fe1fc4410302791ba211292b8092f9d84120a713951d433a3dfb1a237d051a7f5ebe6d31cd47c3f102b93462
|
|
7
|
+
data.tar.gz: 408fb3f24b0928ecf0438a5773c5fafc6404b73139cecbfe470235bcb5476741197bb402054e8b96b1e480b74f3ac19d6564f569db9bfa0c57e4d7e512c22f72
|
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.4.0] - 2026-04-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Result#success_rate` — ratio of succeeded to total items as a Float in `[0.0, 1.0]`; returns `0.0` for empty batches
|
|
14
|
+
|
|
10
15
|
## [0.3.0] - 2026-04-17
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -107,6 +107,13 @@ stats = result.stats
|
|
|
107
107
|
# => { total: 100, succeeded: 97, failed: 3, success_rate: 0.97, elapsed: 1.23 }
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
### Success rate
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
result = Philiprehberger::RetryQueue.process(items, max_retries: 3) { |item| call(item) }
|
|
114
|
+
result.success_rate # => 0.92
|
|
115
|
+
```
|
|
116
|
+
|
|
110
117
|
## API
|
|
111
118
|
|
|
112
119
|
| Method | Description |
|
|
@@ -116,6 +123,7 @@ stats = result.stats
|
|
|
116
123
|
| `Result#succeeded` | Array of successfully processed items |
|
|
117
124
|
| `Result#failed` | Array of hashes with `:item`, `:error`, `:attempts` |
|
|
118
125
|
| `Result#stats` | Hash with `:total`, `:succeeded`, `:failed`, `:success_rate`, `:elapsed` |
|
|
126
|
+
| `Result#success_rate` | Float in `[0.0, 1.0]`; ratio of succeeded to total items (`0.0` for empty batches) |
|
|
119
127
|
| `Result#reprocess_failed { \|item, error\| }` | Reprocess failed items, returns a new Result |
|
|
120
128
|
|
|
121
129
|
## Development
|
|
@@ -28,11 +28,23 @@ module Philiprehberger
|
|
|
28
28
|
total: total,
|
|
29
29
|
succeeded: @succeeded.size,
|
|
30
30
|
failed: @failed.size,
|
|
31
|
-
success_rate:
|
|
31
|
+
success_rate: success_rate,
|
|
32
32
|
elapsed: @elapsed
|
|
33
33
|
}
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# Ratio of succeeded items to total processed items.
|
|
37
|
+
#
|
|
38
|
+
# Returns 0.0 for an empty batch to avoid ZeroDivisionError.
|
|
39
|
+
#
|
|
40
|
+
# @return [Float] ratio in the range [0.0, 1.0]
|
|
41
|
+
def success_rate
|
|
42
|
+
total = @succeeded.size + @failed.size
|
|
43
|
+
return 0.0 if total.zero?
|
|
44
|
+
|
|
45
|
+
@succeeded.size.to_f / total
|
|
46
|
+
end
|
|
47
|
+
|
|
36
48
|
# Reprocess failed items by yielding each item and its last error to the block.
|
|
37
49
|
# Returns a new Result with the reprocessing outcomes.
|
|
38
50
|
#
|
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.4.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-04-
|
|
11
|
+
date: 2026-04-20 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
|