Repository navigation
Add Retry-After header during brownout windows - #9
Conversation
There was a problem hiding this comment.
Pull request overview
Adds brownout window end-time introspection and uses it to attach an RFC 7231 Retry-After header to brownout-triggered 410 responses, enabling clients to retry automatically when the brownout ends.
Changes:
- Introduces
BrownoutChecker::getBrownoutWindowEnd()and refactorsisInBrownoutWindow()to delegate to it. - Updates
DeprecationHeaderListenerto add aRetry-Afterheader on brownout 410s based on the remaining window duration. - Adds/updates PHPUnit coverage for the new window-end API and
Retry-Afterbehavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Brownout/BrownoutChecker.php |
Adds getBrownoutWindowEnd() and refactors isInBrownoutWindow() to use it. |
src/EventListener/DeprecationHeaderListener.php |
Computes and sets Retry-After on brownout 410 responses. |
tests/Brownout/BrownoutCheckerTest.php |
Adds tests for getBrownoutWindowEnd() behavior. |
tests/EventListener/DeprecationHeaderListenerTest.php |
Adds tests asserting Retry-After presence/value in brownout 410s. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Refactor BrownoutChecker to expose getBrownoutWindowEnd() returning the window end time, and use it in DeprecationHeaderListener to include a Retry-After header (RFC 7231 §7.1.3) in 410 responses during brownouts. This lets clients know when to retry after a brownout window closes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
af14d3b to
ea820ea
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances the brownout mechanism by exposing the current brownout window end time and using it to emit an RFC-compliant Retry-After header on 410 responses during brownouts, enabling clients to retry automatically when the window ends.
Changes:
- Add
BrownoutChecker::getBrownoutWindowEnd()and refactorisInBrownoutWindow()to delegate to it. - Add
Retry-After(delta-seconds) header to brownout-triggered410 Goneresponses inDeprecationHeaderListener. - Extend test coverage for both the new window-end API and the new response header behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Brownout/BrownoutChecker.php |
Adds getBrownoutWindowEnd() and refactors brownout-window detection to reuse it. |
src/EventListener/DeprecationHeaderListener.php |
Computes Retry-After during brownouts and adds optional clock injection for deterministic time. |
src/ApiDeprecationBundle.php |
Wires the optional clock service into DeprecationHeaderListener. |
tests/Brownout/BrownoutCheckerTest.php |
Adds unit tests for getBrownoutWindowEnd() behavior and edge cases. |
tests/EventListener/DeprecationHeaderListenerTest.php |
Adds tests validating presence and correctness of the Retry-After header. |
Comments suppressed due to low confidence (1)
src/Brownout/BrownoutChecker.php:30
- Exception message has a trailing period ("Unknown brownout strategy "%s".") but tests assert the message without the period (e.g., BrownoutCheckerTest expects
Unknown brownout strategy "nonexistent"). This will cause test failures and is a breaking change for callers relying on the message; consider removing the trailing period (or update all affected tests/messages consistently).
if (!isset($this->namedStrategies[$strategyName])) {
throw new \InvalidArgumentException(\sprintf('Unknown brownout strategy "%s".', $strategyName));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
getBrownoutWindowEnd()method toBrownoutCheckerreturning the window end timeisInBrownoutWindow()to delegate togetBrownoutWindowEnd()Retry-Afterheader (RFC 7231 §7.1.3) to 410 responses during brownoutsTest plan
getBrownoutWindowEndreturns correctDateTimeImmutablewhen in windowgetBrownoutWindowEndreturns null when outside windowRetry-Afterheader present in brownout 410 responsesRetry-Aftervalue is correct (seconds until window end)🤖 Generated with Claude Code