From 9f133487ffc2ab4539688c29efe57bb1ba31d7b0 Mon Sep 17 00:00:00 2001 From: fumoboy007 <2100868+fumoboy007@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:00:38 -0800 Subject: [PATCH] Add details about `RetryableRequest` to the Overview section of the documentation landing page. --- README.md | 6 ++++++ Sources/Retry/Retry.docc/Retry.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 0306042..d621d59 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,9 @@ The API provides several customization points to accommodate any use case: - The `RetryConfiguration` type encapsulates the retry behavior so that it can be reused across multiple call sites without duplicating code. - The `Backoff` type represents the choice of algorithm that will be used to determine how long to sleep in between attempts. It has built-in support for common algorithms but can be initialized with a custom `BackoffAlgorithm` implementation if needed. - The clock that is used to sleep in between attempts can be replaced. For example, one might use a fake `Clock` implementation in automated tests to ensure the tests are deterministic and efficient. + +### Safe Retries + +The module exposes a `RetryableRequest` protocol to add safe retry methods to a conforming request type. The retry methods in the protocol are similar to the top-level retry functions, but safer. The retry methods in the protocol enforce that the request is idempotent since it is unsafe to retry a non-idempotent request. + +To retry HTTP requests, consider using the [`swift-http-error-handling`](https://swiftpackageindex.com/fumoboy007/swift-http-error-handling) package, which adds `RetryableRequest` conformance to the standard `HTTPRequest` type. diff --git a/Sources/Retry/Retry.docc/Retry.md b/Sources/Retry/Retry.docc/Retry.md index 9a442b7..b522b85 100644 --- a/Sources/Retry/Retry.docc/Retry.md +++ b/Sources/Retry/Retry.docc/Retry.md @@ -22,6 +22,12 @@ The API provides several customization points to accommodate any use case: - The ``Backoff`` type represents the choice of algorithm that will be used to determine how long to sleep in between attempts. It has built-in support for common algorithms but can be initialized with a custom ``BackoffAlgorithm`` implementation if needed. - The ``RetryConfiguration/clock`` that is used to sleep in between attempts can be replaced. For example, one might use a fake `Clock` implementation in automated tests to ensure the tests are deterministic and efficient. +### Safe Retries + +The module exposes a ``RetryableRequest`` protocol to add safe retry methods to a conforming request type. The retry methods in the protocol are similar to the top-level retry functions, but safer. The retry methods in the protocol enforce that the request is idempotent since it is unsafe to retry a non-idempotent request. + +To retry HTTP requests, consider using the [`swift-http-error-handling`](https://swiftpackageindex.com/fumoboy007/swift-http-error-handling) package, which adds ``RetryableRequest`` conformance to the standard `HTTPRequest` type. + ## Topics ### Examples