Skip to content
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

List a retry on HTTP2 INTERNAL_ERROR in changelog #280

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 7.0.0

* `geoipupdate` now supports retrying on more types of errors
such as HTTP2 INTERNAL_ERROR.
* `HTTPReader` no longer retries on HTTP errors and therefore
`retryFor` was removed from `NewHTTPReader`.

Expand Down
12 changes: 6 additions & 6 deletions pkg/geoipupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func setConfigFromFile(config *Config, path string) error {
case "AccountID", "UserId":
accountID, err := strconv.Atoi(value)
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
config.AccountID = accountID
keysSeen["AccountID"] = struct{}{}
Expand Down Expand Up @@ -286,7 +286,7 @@ func setConfigFromEnv(config *Config) error {
var err error
config.AccountID, err = strconv.Atoi(value)
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
}

Expand All @@ -300,7 +300,7 @@ func setConfigFromEnv(config *Config) error {

config.AccountID, err = strconv.Atoi(strings.TrimSpace(string(accountID)))
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
}

Expand Down Expand Up @@ -396,15 +396,15 @@ func validateConfig(config *Config) error {
}

if len(config.EditionIDs) == 0 {
return fmt.Errorf("the `EditionIDs` option is required")
return errors.New("the `EditionIDs` option is required")
}

if config.AccountID == 0 {
return fmt.Errorf("the `AccountID` option is required")
return errors.New("the `AccountID` option is required")
}

if config.LicenseKey == "" {
return fmt.Errorf("the `LicenseKey` option is required")
return errors.New("the `LicenseKey` option is required")
}

return nil
Expand Down
13 changes: 10 additions & 3 deletions pkg/geoipupdate/internal/job_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"context"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -61,8 +62,9 @@ func TestJobQueueRun(t *testing.T) {
// Execute run in a goroutine so that we can exit early if the test
// hangs or takes too long to execute.
go func() {
err := jobProcessor.Run(ctx)
require.NoError(t, err)
if err := jobProcessor.Run(ctx); err != nil {
t.Error(err)
}
close(doneCh)
}()

Expand Down Expand Up @@ -106,7 +108,12 @@ func TestJobQueueStop(t *testing.T) {
// hangs or takes too long to execute.
go func() {
err := jobProcessor.Run(ctx)
require.ErrorContains(t, err, "processing cancelled")
if err == nil {
t.Error(`expected "processing cancelled" error`)
}
if !strings.Contains(err.Error(), "processing cancelled") {
t.Errorf(`expected "processing cancelled" error, got %q`, err)
}
close(doneCh)
}()

Expand Down
Loading