This commit introduces a resilient, configurable retry mechanism for network requests. Key changes include: - A new `pkg/retry` package with a custom `http.Transport` that implements exponential backoff and jitter. - Integration of the retry transport into the `website`, `pwa`, and `github` packages to handle transient network failures gracefully. - New persistent CLI flags (`--retries`, `--retry-backoff`, `--retry-max`, `--retry-jitter`, `--no-retry`) to allow user configuration of the retry behavior. - The flag-handling logic has been moved to a `PersistentPreRun` function to ensure user-provided values are parsed correctly. - A basic retry mechanism has been added to the `vcs` package for git clone operations. - Added unit tests for the retry transport. This work is in progress, with the next steps being to implement support for the `Retry-After` header and unify the VCS retry logic with the global configuration. Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
23 lines
386 B
Go
23 lines
386 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/Snider/Borg/cmd"
|
|
"github.com/Snider/Borg/pkg/logger"
|
|
"github.com/Snider/Borg/pkg/retry"
|
|
)
|
|
|
|
var osExit = os.Exit
|
|
|
|
func main() {
|
|
Main()
|
|
}
|
|
func Main() {
|
|
verbose, _ := cmd.RootCmd.PersistentFlags().GetBool("verbose")
|
|
log := logger.New(verbose)
|
|
if err := cmd.Execute(log); err != nil {
|
|
log.Error("fatal error", "err", err)
|
|
osExit(1)
|
|
}
|
|
}
|