Skip to content

feat(sdk): align create_linear_retry_strategy with create_retry_strategy (parity with JS #652)#484

Merged
yaythomas merged 1 commit into
aws:mainfrom
SAY-5:linear-retry-parity
Jun 18, 2026
Merged

feat(sdk): align create_linear_retry_strategy with create_retry_strategy (parity with JS #652)#484
yaythomas merged 1 commit into
aws:mainfrom
SAY-5:linear-retry-parity

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Closes #483.

What

create_linear_retry_strategy now takes a LinearRetryStrategyConfig (Duration-based) and gains max_delay capping, jitter (default FULL), and retryable_errors / retryable_error_types filtering, matching create_retry_strategy. The shared jitter, error-resolution/matching, and final delay clamp logic is extracted into module-level helpers used by both helpers so they cannot drift.

Why

create_retry_strategy was already config-shaped with those capabilities; the linear helper lagged behind and forced callers to hand-roll a strategy for jitter, a delay cap, or error filtering. This mirrors the JS change in aws/aws-durable-execution-sdk-js#652.

Notes

This is a breaking change, as called out in the issue: the signature moves from positional (max_attempts, initial_delay, increment) to a config object, and a bare create_linear_retry_strategy() now applies FULL jitter. RetryPresets.linear() is pinned to jitter=NONE so its documented deterministic 1s-5s delays are preserved.

Testing

Updated the existing linear tests to the config API and added coverage for the new max_delay cap, jitter application, and message/type error filtering. hatch run test:cov passes locally for tests/retries_test.py.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please exclude from commit :-)

return is_retryable_error_message or is_retryable_error_type


def _finalize_delay_seconds(base_delay: float, jitter_strategy: JitterStrategy) -> int:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could move to JitterStrategy and then it's nicely encapsulated in the Jitter object...

   # on JitterStrategy
   def finalize_delay(self, base_delay: float) -> int:
       return max(1, math.ceil(self.apply_jitter(base_delay)))

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5 SAY-5 force-pushed the linear-retry-parity branch from 89528bd to 95c2a80 Compare June 18, 2026 22:52
@SAY-5

SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Dropped uv.lock from the branch and moved the finalize step onto the strategy as JitterStrategy.finalize_delay, so both creators now just call config.jitter_strategy.finalize_delay(base_delay). Tests still green.

@yaythomas

Copy link
Copy Markdown
Contributor

great contribution, thank you so much @SAY-5! welcome to the repo 😁

@yaythomas yaythomas merged commit 48d0dd8 into aws:main Jun 18, 2026
6 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sdk): align create_linear_retry_strategy with create_retry_strategy (parity with JS #652)

2 participants