Module: Ace::Hitl::Hermes::Molecules::HermesRetryPolicy
- Defined in:
- lib/ace/hitl/hermes/molecules/hermes_retry_policy.rb
Overview
Pure retry decisions (spec 8wm.t.vs1 §8). The clock-and-loop belongs to the transport role (y24 / A4); this module pins the policy so both sides decide identically.
- collision retries (write time): bounded fresh-id attempts;
- undeleted-file retries (post-delivery): a delivered file that is not ACKed after the stale deadline is redelivered as IDENTICAL bytes, bounded, then quarantined (terminal).
Constant Summary collapse
- DEFAULT_MAX_ATTEMPTS =
3- DEFAULT_BASE_DELAY =
1.0- DEFAULT_MAX_DELAY =
60.0
Class Method Summary collapse
- .collision_retry?(failed_attempts, max_attempts: DEFAULT_MAX_ATTEMPTS) ⇒ Boolean
-
.delay_for(attempt, base_delay: DEFAULT_BASE_DELAY, max_delay: DEFAULT_MAX_DELAY) ⇒ Object
Exponential backoff for the given 1-based attempt number.
-
.undeleted_decision(age_seconds:, stale_after:, attempts:, max_attempts: DEFAULT_MAX_ATTEMPTS) ⇒ Object
Decision for a delivered-but-not-acked file.
Class Method Details
.collision_retry?(failed_attempts, max_attempts: DEFAULT_MAX_ATTEMPTS) ⇒ Boolean
21 22 23 |
# File 'lib/ace/hitl/hermes/molecules/hermes_retry_policy.rb', line 21 def collision_retry?(failed_attempts, max_attempts: DEFAULT_MAX_ATTEMPTS) failed_attempts < max_attempts end |
.delay_for(attempt, base_delay: DEFAULT_BASE_DELAY, max_delay: DEFAULT_MAX_DELAY) ⇒ Object
Exponential backoff for the given 1-based attempt number.
26 27 28 |
# File 'lib/ace/hitl/hermes/molecules/hermes_retry_policy.rb', line 26 def delay_for(attempt, base_delay: DEFAULT_BASE_DELAY, max_delay: DEFAULT_MAX_DELAY) [base_delay * (2**(attempt - 1)), max_delay].min end |
.undeleted_decision(age_seconds:, stale_after:, attempts:, max_attempts: DEFAULT_MAX_ATTEMPTS) ⇒ Object
Decision for a delivered-but-not-acked file.
attempts = deliveries already performed (>= 1).
32 33 34 35 36 37 |
# File 'lib/ace/hitl/hermes/molecules/hermes_retry_policy.rb', line 32 def undeleted_decision(age_seconds:, stale_after:, attempts:, max_attempts: DEFAULT_MAX_ATTEMPTS) return :wait if age_seconds < stale_after return :redeliver if attempts < max_attempts :quarantine end |