chrono_machines 0.5.2-aarch64-linux → 0.8.0-aarch64-linux

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
  SHA256:
3
- metadata.gz: 68b631929b511e3dbf0c4b56892fee0f06a61cc58725754e1bff530a1322f5c4
4
- data.tar.gz: ee7cd1668c92bec178c0e055a51f9df65f104dd2ed1aa2ea929442ec85629f5a
3
+ metadata.gz: f7ca19a090aa72fe3328def5fb7606623759f52954f5008e4ce8057010553ccb
4
+ data.tar.gz: b3495731fe352c6a6f7b87e7c91180c820cb15ccdab6fb735d798d2f8e2b628c
5
5
  SHA512:
6
- metadata.gz: fb0e387bbdab562206841981d10286118d8f7eedf81beaaf6aa8778de0d8b57d5d086e05addaf416655ec44da046d0e6810947d3a9c5b388c494c4e49f05b7a1
7
- data.tar.gz: 5711529c48fc6be1510ac756051cb149b636cdda4fddd002d7d56168e869626188217c31cdac8967d8b200b01aa492f525779fdf3c159d61f0235a2d7d498cb5
6
+ metadata.gz: a82ecf502472e225de23f62bb9d71a6234bd9bed1be9167a2800e1ba04c6abf9027f7f6eda8d97fcabab44bb8f0e8bb15accd49aa132a0fa9b187c2dceb4c714
7
+ data.tar.gz: 412154adcbca21fe7e3c67be8fdac662438320e9505c4c8dd5fd3f4ee41407ed4aaeed30db2d6ceaaf41da54abb014fdb29e13b454df82f8008c57a2a23de418
data/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.8.0](https://github.com/seuros/chrono_machines/compare/chrono_machines/v0.5.0...chrono_machines/v0.8.0) (2026-09-14)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21))
9
+
10
+ ### Features
11
+
12
+ * **core:** delay_from - server-hinted retry delays (HTTP Retry-After) ([#25](https://github.com/seuros/chrono_machines/issues/25)) ([2dcf987](https://github.com/seuros/chrono_machines/commit/2dcf9871939b70c053144e9fc296914a3b6105e5))
13
+ * **core:** re-export rand so BackoffStrategy is implementable downstream ([dc1cf49](https://github.com/seuros/chrono_machines/commit/dc1cf494df0124032bec6aee6e4f6a33e43abbfb))
14
+ * fix release ([ad40d8f](https://github.com/seuros/chrono_machines/commit/ad40d8f5b6629e49ba2d5f0cb7f213a1cc1e30c7))
15
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21)) ([766f207](https://github.com/seuros/chrono_machines/commit/766f20799bcc0c36f7ca6a904fadff227549fee7))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * ignore native_speedup.rb in Zeitwerk loader ([#19](https://github.com/seuros/chrono_machines/issues/19)) ([491cc2d](https://github.com/seuros/chrono_machines/commit/491cc2d3f88786cf6d0c6af68dba7d2511fa3f36))
21
+ * package workspace Cargo manifest so source builds work ([#17](https://github.com/seuros/chrono_machines/issues/17)) ([ac0ddad](https://github.com/seuros/chrono_machines/commit/ac0ddad15d26528771825240a05ed8c84fb61520))
22
+ * trigger release ([02184d5](https://github.com/seuros/chrono_machines/commit/02184d51f6831f53ae6142ea5092710d456363d5))
23
+
24
+ ## [0.5.0](https://github.com/seuros/chrono_machines/compare/chrono_machines/v0.5.0...chrono_machines/v0.5.0) (2026-09-14)
25
+
26
+
27
+ ### ⚠ BREAKING CHANGES
28
+
29
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21))
30
+
31
+ ### Features
32
+
33
+ * **core:** delay_from - server-hinted retry delays (HTTP Retry-After) ([#25](https://github.com/seuros/chrono_machines/issues/25)) ([2dcf987](https://github.com/seuros/chrono_machines/commit/2dcf9871939b70c053144e9fc296914a3b6105e5))
34
+ * **core:** re-export rand so BackoffStrategy is implementable downstream ([dc1cf49](https://github.com/seuros/chrono_machines/commit/dc1cf494df0124032bec6aee6e4f6a33e43abbfb))
35
+ * fix release ([ad40d8f](https://github.com/seuros/chrono_machines/commit/ad40d8f5b6629e49ba2d5f0cb7f213a1cc1e30c7))
36
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21)) ([766f207](https://github.com/seuros/chrono_machines/commit/766f20799bcc0c36f7ca6a904fadff227549fee7))
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * ignore native_speedup.rb in Zeitwerk loader ([#19](https://github.com/seuros/chrono_machines/issues/19)) ([491cc2d](https://github.com/seuros/chrono_machines/commit/491cc2d3f88786cf6d0c6af68dba7d2511fa3f36))
42
+ * package workspace Cargo manifest so source builds work ([#17](https://github.com/seuros/chrono_machines/issues/17)) ([ac0ddad](https://github.com/seuros/chrono_machines/commit/ac0ddad15d26528771825240a05ed8c84fb61520))
43
+
44
+ ## [0.5.0](https://github.com/seuros/chrono_machines/compare/chrono_machines/v0.5.0...chrono_machines/v0.5.0) (2026-08-23)
45
+
46
+
47
+ ### ⚠ BREAKING CHANGES
48
+
49
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21))
50
+
51
+ ### Features
52
+
53
+ * **core:** re-export rand so BackoffStrategy is implementable downstream ([dc1cf49](https://github.com/seuros/chrono_machines/commit/dc1cf494df0124032bec6aee6e4f6a33e43abbfb))
54
+ * fix release ([ad40d8f](https://github.com/seuros/chrono_machines/commit/ad40d8f5b6629e49ba2d5f0cb7f213a1cc1e30c7))
55
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21)) ([766f207](https://github.com/seuros/chrono_machines/commit/766f20799bcc0c36f7ca6a904fadff227549fee7))
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * ignore native_speedup.rb in Zeitwerk loader ([#19](https://github.com/seuros/chrono_machines/issues/19)) ([491cc2d](https://github.com/seuros/chrono_machines/commit/491cc2d3f88786cf6d0c6af68dba7d2511fa3f36))
61
+ * package workspace Cargo manifest so source builds work ([#17](https://github.com/seuros/chrono_machines/issues/17)) ([ac0ddad](https://github.com/seuros/chrono_machines/commit/ac0ddad15d26528771825240a05ed8c84fb61520))
62
+
63
+ ## [0.5.0](https://github.com/seuros/chrono_machines/compare/chrono_machines/v0.5.2...chrono_machines/v0.5.0) (2026-08-23)
64
+
65
+
66
+ ### ⚠ BREAKING CHANGES
67
+
68
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21))
69
+
70
+ ### Features
71
+
72
+ * fix release ([ad40d8f](https://github.com/seuros/chrono_machines/commit/ad40d8f5b6629e49ba2d5f0cb7f213a1cc1e30c7))
73
+ * **native:** add async retry driver ([#21](https://github.com/seuros/chrono_machines/issues/21)) ([766f207](https://github.com/seuros/chrono_machines/commit/766f20799bcc0c36f7ca6a904fadff227549fee7))
74
+
3
75
  ## [0.5.2](https://github.com/seuros/chrono_machines/compare/chrono_machines/v0.5.1...chrono_machines/v0.5.2) (2026-08-07)
4
76
 
5
77
 
data/README.md CHANGED
@@ -195,6 +195,32 @@ ChronoMachines.retry(
195
195
  end
196
196
  ```
197
197
 
198
+ ### Server-Hinted Delays (`delay_from`)
199
+
200
+ When the server tells you when to come back - HTTP 429 with `Retry-After` - guessing with exponential backoff is rude. `delay_from` lets the exception dictate the next delay:
201
+
202
+ ```ruby
203
+ ChronoMachines.retry(
204
+ max_attempts: 5,
205
+ max_delay: 30,
206
+ retryable_exceptions: [MyClient::RateLimitError],
207
+ delay_from: ->(exception:, attempt:) {
208
+ exception.respond_to?(:retry_after) ? exception.retry_after : nil
209
+ }
210
+ ) do
211
+ call_rate_limited_api
212
+ end
213
+ ```
214
+
215
+ The hook's return value controls the retry:
216
+
217
+ - `nil` - no hint; fall back to the policy's backoff strategy
218
+ - `Numeric` - sleep exactly that many seconds (no jitter: the server picked the time, honor it)
219
+ - a `Numeric` **beyond `max_delay`** - halt: the server asked for more patience than this policy allows, so the original exception propagates and the caller decides (background job, `Retry-After` response header, ...)
220
+ - `:halt` or `false` - stop retrying immediately, propagate the original exception
221
+
222
+ Anything else raises `ArgumentError` - a broken hook fails loudly instead of silently mangling your retry cadence.
223
+
198
224
  ## The Science of Temporal Jitter
199
225
 
200
226
  ChronoMachines implements **full jitter** exponential backoff:
@@ -18,6 +18,7 @@ module ChronoMachines
18
18
  max_delay: 10, # seconds
19
19
  jitter_factor: 1.0, # 1.0 = full jitter (recommended), 0.0 = no jitter
20
20
  retryable_exceptions: [StandardError],
21
+ delay_from: nil, # Optional delay override from the exception (e.g. HTTP Retry-After)
21
22
  on_failure: nil, # Fallback block when all retries are exhausted
22
23
  on_retry: nil, # Callback block when a retry occurs
23
24
  on_success: nil # Callback block when operation succeeds
@@ -16,6 +16,7 @@ module ChronoMachines
16
16
  @max_delay = policy_options[:max_delay]
17
17
  @jitter_factor = policy_options[:jitter_factor]
18
18
  @retryable_exceptions = policy_options[:retryable_exceptions]
19
+ @delay_from = policy_options[:delay_from]
19
20
  @on_failure = policy_options[:on_failure]
20
21
  @on_retry = policy_options[:on_retry]
21
22
  @on_success = policy_options[:on_success]
@@ -47,7 +48,7 @@ module ChronoMachines
47
48
  end
48
49
 
49
50
  # Calculate delay
50
- delay = calculate_delay(attempts)
51
+ delay = resolve_delay(e, attempts)
51
52
 
52
53
  # Call retry callback if defined
53
54
  @on_retry&.call(exception: e, attempt: attempts, next_delay: delay)
@@ -60,6 +61,29 @@ module ChronoMachines
60
61
 
61
62
  private
62
63
 
64
+ # delay_from(exception:, attempt:) overrides the backoff: nil -> backoff,
65
+ # Numeric -> verbatim (beyond max_delay: halt), :halt/false -> re-raise.
66
+ def resolve_delay(exception, attempts)
67
+ return calculate_delay(attempts) unless @delay_from
68
+
69
+ hint = @delay_from.call(exception: exception, attempt: attempts)
70
+ case hint
71
+ when nil
72
+ calculate_delay(attempts)
73
+ when Numeric
74
+ if @max_delay && hint > @max_delay
75
+ handle_final_failure(exception, attempts)
76
+ raise exception
77
+ end
78
+ hint
79
+ when :halt, false
80
+ handle_final_failure(exception, attempts)
81
+ raise exception
82
+ else
83
+ raise ArgumentError, "delay_from must return nil, a Numeric, :halt or false; got #{hint.inspect}"
84
+ end
85
+ end
86
+
63
87
  # Pure Ruby implementation of delay calculation (exponential backoff)
64
88
  def ruby_calculate_delay_exponential(attempts)
65
89
  base_exponential_delay = [@base_delay * (@multiplier**(attempts - 1)), @max_delay].min
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChronoMachines
4
- VERSION = '0.5.2'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrono_machines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.8.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-07 00:00:00.000000000 Z
11
+ date: 2026-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk