Skip to content

Commit

Permalink
services/horizon: make our fork of throttled the primary dependency (#…
Browse files Browse the repository at this point in the history
…1642)

Make @bartekn's fork of the `throttled` dependency the primary dependency for that dependency instead of being just a custom source, which is now hosted at `github.com/stellar/throttled`.

This is part of the initiative to move to Modules (#1634) and is a small change to simplify our Gopkg.toml/lock files to make that transition possible and simpler.

Using the fork seems to be confusing the go tooling in go1.12 and go1.13rc1, with both behaving a little differently. There is an issue open golang/go#33795 about it. The issue seems to be limited to replacing modules that don't have a `go.mod`, which is the case with the `throttled` module. Since this fork is the only fork of a dependency we use and it is simple package, it is straight forward for us to switch to using the fork fully in name rather than to try and make it work consistently with both versions, and we did that in bartekn/throttled#2. See that issue for more details about why we felt like this is the right move.

For context, in modules a `replace` directive is how we tell the go toolchain that we want to use a fork of a module. However, a replace statement only applies when go commands are executed inside this repo as the main module and so importers of our repo won't be using the fork. This doesn't really matter for `throttled` because we only use it in `internal` and `main` modules of `horizon`, but because of this the go toolchain does care about the original source since importers of our repo will get the original source, not the replacement.

The revision of `stellar/throttled` that we are importing did change. You can see the diff here:
stellar/throttled@c99eef3...89d7581
  • Loading branch information
leighmcculloch authored Aug 26, 2019
1 parent 7a5d10c commit bfbb52c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
17 changes: 8 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@
revision = "070c81def33f6362a8267b6a4e56fb7bf23fc6b5"

[[constraint]]
name = "github.com/throttled/throttled"
source = "https://github.com/bartekn/throttled.git"
revision = "c99eef3ad70a3be5a983770523e0e379699c805c"
name = "github.com/stellar/throttled"
revision = "89d75816f59db3124e575e96b35d4b7d927cde93"

[[constraint]]
name = "golang.org/x/crypto"
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
apkg "github.com/stellar/go/support/app"
support "github.com/stellar/go/support/config"
"github.com/stellar/go/support/log"
"github.com/throttled/throttled"
"github.com/stellar/throttled"
)

var config horizon.Config
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/actions/rate_limiter_provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package actions

import "github.com/throttled/throttled"
import "github.com/stellar/throttled"

// RateLimiterProvider is an interface that provides access to the type's HTTPRateLimiter.
type RateLimiterProvider interface {
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/stellar/go/support/db"
"github.com/stellar/go/support/errors"
"github.com/stellar/go/support/log"
"github.com/throttled/throttled"
"github.com/stellar/throttled"
"golang.org/x/net/http2"
graceful "gopkg.in/tylerb/graceful.v1"
)
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/sirupsen/logrus"
"github.com/throttled/throttled"
"github.com/stellar/throttled"
)

// Config is the configuration for horizon. It gets populated by the
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/stellar/go/services/horizon/internal/actions"
"github.com/stellar/go/services/horizon/internal/test"
supportLog "github.com/stellar/go/support/log"
"github.com/throttled/throttled"
"github.com/stellar/throttled"
)

func NewTestApp() *App {
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"

"github.com/stellar/go/services/horizon/internal/test"
"github.com/stellar/throttled"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/throttled/throttled"
)

type RateLimitMiddlewareTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/stellar/go/support/db"
"github.com/stellar/go/support/log"
"github.com/stellar/go/support/render/problem"
"github.com/throttled/throttled"
"github.com/stellar/throttled"
)

const LRUCacheSize = 50000
Expand Down

0 comments on commit bfbb52c

Please sign in to comment.