-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📚 docs: Add Retry Addon documentation #3330
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request enhances the retry addon documentation for Fiber by introducing a new example in the README and adding a separate documentation file. The README now includes a complete Changes
Sequence Diagram(s)sequenceDiagram
participant M as Main Function
participant EB as ExponentialBackoff
participant NR as Network Request
M->>EB: Initialize ExponentialBackoff
loop Retry Attempts
M->>NR: Execute Network Request
NR-->>M: Return response or error
alt Failure (error or non-200)
M->>EB: Wait using exponential backoff
else Success (status 200)
M-->>EB: Proceed with successful response
end
end
M->>M: Panic if all retries fail
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3330 +/- ##
==========================================
+ Coverage 84.21% 84.27% +0.06%
==========================================
Files 116 116
Lines 11577 11577
==========================================
+ Hits 9749 9757 +8
+ Misses 1397 1391 -6
+ Partials 431 429 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (2)
addon/retry/README.md (2)
10-17
: 🛠️ Refactor suggestionUpdate TOC Link Fragment Consistency.
The Table of Contents includes the link Default Config Example, but no section exists with that exact anchor. To resolve the markdownlint error (MD051) and avoid confusing readers, please either update the link to match an existing heading (for example, Default Config) or rename the corresponding section heading to "Default Config Example."🧰 Tools
🪛 LanguageTool
[duplication] ~15-~15: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...(ENGLISH_WORD_REPEAT_RULE)
🪛 GitHub Check: markdownlint
[failure] 17-17: Link fragments should be valid
addon/retry/README.md:17:3 MD051/link-fragments Link fragments should be valid [Context: "Default Config Example"] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md051.md🪛 GitHub Actions: markdownlint
[error] 17-17: MD051/link-fragments Link fragments should be valid [Context: 'Default Config Example']
116-127
: 🛠️ Refactor suggestionAlign Section Heading with TOC.
The section that declares the default configuration variable is titled "## Default Config," yet the Table of Contents lists a link for Default Config Example. For consistency and to fix the markdownlint error, please rename the section header (e.g., to "## Default Config Example") or adjust the TOC accordingly.
🧹 Nitpick comments (2)
addon/retry/README.md (1)
27-63
: Clarify Example Code Variable Naming.
The example in themain
function neatly illustrates how to useretry.NewExponentialBackoff
. However, note that the local variable namedclient
(declared inside the retry callback) shares its name with the imported package. To avoid any potential shadowing or confusion, consider renaming the local variable (for instance, toc
orhttpClient
).docs/addon/retry.md (1)
29-67
: Refine Example Code for Consistency.
The provided example effectively demonstrates the usage of the retry addon. Similar to the README, the callback declares a local variable namedclient
that might conflict with the imported package identifier. Consider renaming this local variable to improve clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
docs/addon/_category_.json
is excluded by!**/*.json
docs/client/_category_.json
is excluded by!**/*.json
docs/extra/_category_.json
is excluded by!**/*.json
docs/guide/_category_.json
is excluded by!**/*.json
📒 Files selected for processing (2)
addon/retry/README.md
(2 hunks)docs/addon/retry.md
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: markdownlint
addon/retry/README.md
[error] 17-17: MD051/link-fragments Link fragments should be valid [Context: 'Default Config Example']
🪛 LanguageTool
docs/addon/retry.md
[duplication] ~19-~19: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...
(ENGLISH_WORD_REPEAT_RULE)
🪛 GitHub Check: markdownlint
docs/addon/retry.md
[failure] 21-21: Link fragments should be valid
docs/addon/retry.md:21:3 MD051/link-fragments Link fragments should be valid [Context: "Default Config Example"] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md051.md
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: unit (1.24.x, macos-13)
- GitHub Check: unit (1.24.x, macos-latest)
- GitHub Check: unit (1.24.x, windows-latest)
- GitHub Check: unit (1.23.x, macos-latest)
- GitHub Check: unit (1.23.x, windows-latest)
- GitHub Check: Compare
- GitHub Check: Analyse
- GitHub Check: repeated
## Table of Contents | ||
|
||
- [Retry Addon](#retry-addon) | ||
- [Table of Contents](#table-of-contents) | ||
- [Signatures](#signatures) | ||
- [Examples](#examples) | ||
- [Default Config](#default-config) | ||
- [Custom Config](#custom-config) | ||
- [Config](#config) | ||
- [Default Config Example](#default-config-example) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ensure Valid TOC Links.
Within the Table of Contents, the link Default Config Example does not match any section heading in the document. To improve navigation and address markdownlint MD051, please update the link so that it corresponds to an existing anchor (for example, matching a header renamed to "## Default Config Example") or modify the TOC entry accordingly.
🧰 Tools
🪛 LanguageTool
[duplication] ~19-~19: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...
(ENGLISH_WORD_REPEAT_RULE)
🪛 GitHub Check: markdownlint
[failure] 21-21: Link fragments should be valid
docs/addon/retry.md:21:3 MD051/link-fragments Link fragments should be valid [Context: "Default Config Example"] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md051.md
docs/addon/retry.md
Outdated
## Default Config | ||
|
||
```go | ||
// DefaultConfig is the default config for retry. | ||
var DefaultConfig = Config{ | ||
InitialInterval: 1 * time.Second, | ||
MaxBackoffTime: 32 * time.Second, | ||
Multiplier: 2.0, | ||
MaxRetryCount: 10, | ||
currentInterval: 1 * time.Second, | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consistent Section Naming Recommended.
The section header for the default configuration variable is labeled "## Default Config" but is referenced in the TOC as Default Config Example. Renaming this header to "## Default Config Example" would ensure uniformity across the document and resolve the link fragment issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
addon/retry/README.md (1)
1-7
: Improve Description Clarity in the Introduction
The introductory paragraph explains the addon’s purpose well, but the sentence “If all calls are failed, then, it returns an error.” can be rephrased for clarity. Consider updating it to:-If all calls are failed, then, it returns an error. +If all calls fail, an error is returned.This change improves readability and grammatical accuracy.
docs/addon/retry.md (1)
1-11
: Enhance Introduction Wording in YAML Documentation
The YAML front matter and introductory section effectively introduce the Retry Addon. However, similar to the README, consider rephrasing the sentence in the introduction to avoid repetition and improve clarity. For example:-If all calls are failed, then, it returns an error. It adds a jitter at each retry step because adding - a jitter is a way to break synchronization across the client and avoid collision. +If all calls fail, an error is returned. A jitter is added at each retry step to break client synchronization and avoid collisions.This revision removes redundant wording and makes the description more concise.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
addon/retry/README.md
(2 hunks)docs/addon/retry.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/addon/retry.md
[duplication] ~19-~19: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...
(ENGLISH_WORD_REPEAT_RULE)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: unit (1.24.x, macos-13)
- GitHub Check: unit (1.24.x, macos-latest)
- GitHub Check: unit (1.24.x, windows-latest)
- GitHub Check: unit (1.23.x, macos-13)
- GitHub Check: unit (1.23.x, windows-latest)
- GitHub Check: Compare
- GitHub Check: repeated
🔇 Additional comments (5)
addon/retry/README.md (2)
8-18
: Table of Contents Validation
The Table of Contents accurately lists all key sections, including “Default Config Example.” Ensure that the corresponding section header exactly matches the TOC entry so that in-page navigation works correctly. Currently, the TOC entry “Default Config Example” aligns with the later header, so no changes are necessary here.🧰 Tools
🪛 LanguageTool
[duplication] ~15-~15: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...(ENGLISH_WORD_REPEAT_RULE)
25-63
: Examples Code Block – Clear and Comprehensive
The complete example in the “Examples” section demonstrates how to initialize the exponential backoff and perform a network request with retry logic. The inline comments make the code easy to follow. One consideration: while usingpanic(err)
is acceptable in a demonstrative context, you might want to note (in comments) that in production code more graceful error handling could be preferable.docs/addon/retry.md (3)
12-22
: Table of Contents Consistency
The TOC accurately reflects the document’s sections, and the link “Default Config Example” now matches the header “## Default Config Example.” This resolves previous navigation issues and aligns with best practices for markdown links.🧰 Tools
🪛 LanguageTool
[duplication] ~19-~19: Possible typo: you repeated a word.
Context: ...ault Config](#default-config) - Custom Config - Config - [Default Config Example](#d...(ENGLISH_WORD_REPEAT_RULE)
29-67
: Examples Code Block – Clear Demonstration
The “Examples” section provides a full, illustrative usage example of the retry functionality. The sample code is clear, well-commented, and effectively demonstrates how to handle errors during retries using the exponential backoff mechanism.
69-128
: Configuration and Default Config Example Sections are Well Structured
The “Default Config,” “Custom Config,” “Config,” and “Default Config Example” sections comprehensively document the addon's configuration options. The code examples are consistent and maintain a clear style throughout the document. These sections offer valuable, easily digestible information for users looking to customize their retry behavior.
## Signatures | ||
|
||
```go | ||
func NewExponentialBackoff(config ...Config) *ExponentialBackoff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use rety.Config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- pls add the addon to the https://docs.gofiber.io/next/whats_new markdown
"collapsed": true, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Addons are additional useful packages that can be used in Fiber." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say:
Addon is an additional useful package that can be used in Fiber.
// currentInterval tracks the current waiting time. | ||
// | ||
// Optional. Default: 1 * time.Second | ||
currentInterval time.Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a private config option, I dont think it needs to be here in the docs.
@grivera64 can you check our hints |
Description
Fiber added its first add-on in PR #1972, called retry. The documentation for this add-on is not currently included in v3's documentation on docs.gofiber.io.
This PR adds this missing documentation under a new collapsible tab under the middleware tab.
Fixes #3326
Changes introduced
retry
Type of change
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/
directory for Fiber's documentation.