Skip to content

Add retrier interface and exponential backoff class.#15

Merged
parthban-db merged 2 commits into
mainfrom
parthban-db/stack/api-execute-retrier
Mar 2, 2026
Merged

Add retrier interface and exponential backoff class.#15
parthban-db merged 2 commits into
mainfrom
parthban-db/stack/api-execute-retrier

Conversation

@parthban-db
Copy link
Copy Markdown
Contributor

@parthban-db parthban-db commented Feb 27, 2026

🥞 Stacked PR

Use this link to review incremental changes.


What changes are proposed in this pull request?

Add the api module with retry infrastructure, ported from the Go SDK's api/retrier.go. This is the first building block of the API execution layer.

  • BackoffPolicy — exponential backoff with jitter, computing a random delay in [0, current] that grows by a configurable factor and is capped at a maximum. Based on the Exponential Backoff And Jitter pattern.
  • Retrier — interface for retry decisions, returning a delay in milliseconds or undefined if the error is not retriable.
  • retryOn — factory function that pairs a backoff policy with a custom predicate to produce a Retrier.
  • BackoffPolicyOptions — exported configuration interface with JSDoc.

Notable deviations from Go:

  • time.Duration → milliseconds as number.
  • Retrier.isRetriable returns number | undefined instead of (Duration, bool) — idiomatic TypeScript.

How is this tested?

Unit tests.

@parthban-db parthban-db marked this pull request as ready for review February 27, 2026 13:02
@parthban-db parthban-db mentioned this pull request Feb 27, 2026
@parthban-db parthban-db force-pushed the parthban-db/stack/api-execute-retrier branch 2 times, most recently from f28ff0f to 81d6f86 Compare February 27, 2026 14:45
@parthban-db parthban-db force-pushed the parthban-db/stack/api-execute-retrier branch from 81d6f86 to 54f4dd9 Compare February 27, 2026 15:14
@Divyansh-db
Copy link
Copy Markdown
Contributor

Just a question, why have we not implemented RetryOnCode() as it exists in Go SDK?

@parthban-db
Copy link
Copy Markdown
Contributor Author

parthban-db commented Mar 2, 2026

Just a question, why have we not implemented RetryOnCode() as it exists in Go SDK?

Yeah, I will do that later. This PR doesn't complete the porting.

@parthban-db parthban-db enabled auto-merge March 2, 2026 17:08
@parthban-db parthban-db added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit a33f5c0 Mar 2, 2026
9 checks passed
@parthban-db parthban-db deleted the parthban-db/stack/api-execute-retrier branch May 12, 2026 15:37
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.

2 participants