Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #94 from mailgun/maxim/develop
Browse files Browse the repository at this point in the history
PIP-1319: Update to the latest etcd client
  • Loading branch information
horkhe authored Jul 2, 2021
2 parents 26a6758 + bf9071f commit cc98f3a
Show file tree
Hide file tree
Showing 48 changed files with 1,878 additions and 1,011 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ __pycache__
*.pyc
gubernator.egg-info/
.DS_Store
*.iml
*.iml
googleapis/
2 changes: 1 addition & 1 deletion algorithms.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package gubernator

import (
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v4/clock"
)

// Implements token bucket algorithm for rate limiting. https://en.wikipedia.org/wiki/Token_bucket
Expand Down
6 changes: 3 additions & 3 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"testing"

guber "github.com/mailgun/gubernator"
"github.com/mailgun/gubernator/cluster"
"github.com/mailgun/holster/v3/syncutil"
guber "github.com/mailgun/gubernator/v2"
"github.com/mailgun/gubernator/v2/cluster"
"github.com/mailgun/holster/v4/syncutil"
)

func BenchmarkServer_GetPeerRateLimitNoBatching(b *testing.B) {
Expand Down
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"container/list"
"sync"

"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/setter"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/setter"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"math/rand"
"time"

"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v4/clock"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down
4 changes: 2 additions & 2 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"fmt"
"math/rand"

"github.com/mailgun/gubernator"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/gubernator/v2"
"github.com/mailgun/holster/v4/clock"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
Expand Down
4 changes: 2 additions & 2 deletions cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package cluster_test
import (
"testing"

"github.com/mailgun/gubernator"
"github.com/mailgun/gubernator/cluster"
"github.com/mailgun/gubernator/v2"
"github.com/mailgun/gubernator/v2/cluster"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
8 changes: 4 additions & 4 deletions cmd/gubernator-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"os"

"github.com/davecgh/go-spew/spew"
guber "github.com/mailgun/gubernator"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/setter"
"github.com/mailgun/holster/v3/syncutil"
guber "github.com/mailgun/gubernator/v2"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/setter"
"github.com/mailgun/holster/v4/syncutil"
"github.com/sirupsen/logrus"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/gubernator-cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"os"
"os/signal"

"github.com/mailgun/gubernator"
"github.com/mailgun/gubernator/cluster"
"github.com/mailgun/gubernator/v2"
"github.com/mailgun/gubernator/v2/cluster"
"github.com/sirupsen/logrus"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/gubernator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"runtime"
"syscall"

"github.com/mailgun/gubernator"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/gubernator/v2"
"github.com/mailgun/holster/v4/clock"
"github.com/sirupsen/logrus"
"k8s.io/klog"
)
Expand Down
42 changes: 10 additions & 32 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import (
"strings"
"time"

etcd "github.com/coreos/etcd/clientv3"
"github.com/davecgh/go-spew/spew"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/setter"
"github.com/mailgun/holster/v3/slice"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/setter"
"github.com/mailgun/holster/v4/slice"
"github.com/pkg/errors"
"github.com/segmentio/fasthash/fnv1"
"github.com/segmentio/fasthash/fnv1a"
"github.com/sirupsen/logrus"
etcd "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *Config) SetDefaults() error {
setter.SetDefault(&c.Behaviors.MultiRegionBatchLimit, maxBatchSize)
setter.SetDefault(&c.Behaviors.MultiRegionSyncWait, time.Second)

setter.SetDefault(&c.LocalPicker, NewReplicatedConsistentHash(nil, DefaultReplicas))
setter.SetDefault(&c.LocalPicker, NewReplicatedConsistentHash(nil, defaultReplicas))
setter.SetDefault(&c.RegionPicker, NewRegionPicker(nil))
setter.SetDefault(&c.Cache, NewLRUCache(0))

Expand Down Expand Up @@ -334,27 +334,13 @@ func SetupDaemonConfig(logger *logrus.Logger, configFile string) (DaemonConfig,
var hash string

switch pp {
case "consistent-hash":
setter.SetDefault(&hash, os.Getenv("GUBER_PEER_PICKER_HASH"), "fnv1a")
hashFuncs := map[string]HashFunc{
"fnv1a": fnv1a.HashBytes32,
"fnv1": fnv1.HashBytes32,
"crc32": nil,
}
fn, ok := hashFuncs[hash]
if !ok {
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHashKeys(hashFuncs))
}
conf.Picker = NewConsistentHash(fn)

case "replicated-hash":
setter.SetDefault(&replicas, getEnvInteger(log, "GUBER_REPLICATED_HASH_REPLICAS"), DefaultReplicas)
setter.SetDefault(&replicas, getEnvInteger(log, "GUBER_REPLICATED_HASH_REPLICAS"), defaultReplicas)
conf.Picker = NewReplicatedConsistentHash(nil, replicas)
setter.SetDefault(&hash, os.Getenv("GUBER_PEER_PICKER_HASH"), "fnv1a")
hashFuncs := map[string]HashFunc64{
"fnv1a": fnv1a.HashBytes64,
"fnv1": fnv1.HashBytes64,
hashFuncs := map[string]HashString64{
"fnv1a": fnv1a.HashString64,
"fnv1": fnv1.HashString64,
}
fn, ok := hashFuncs[hash]
if !ok {
Expand Down Expand Up @@ -542,15 +528,7 @@ func validClientAuthTypes(m map[string]tls.ClientAuthType) string {
return strings.Join(rs, ",")
}

func validHashKeys(m map[string]HashFunc) string {
var rs []string
for k, _ := range m {
rs = append(rs, k)
}
return strings.Join(rs, ",")
}

func validHash64Keys(m map[string]HashFunc64) string {
func validHash64Keys(m map[string]HashString64) string {
var rs []string
for k, _ := range m {
rs = append(rs, k)
Expand Down
6 changes: 3 additions & 3 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"google.golang.org/grpc/keepalive"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/mailgun/holster/v3/etcdutil"
"github.com/mailgun/holster/v3/setter"
"github.com/mailgun/holster/v3/syncutil"
"github.com/mailgun/holster/v4/etcdutil"
"github.com/mailgun/holster/v4/setter"
"github.com/mailgun/holster/v4/syncutil"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down
8 changes: 4 additions & 4 deletions etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"context"
"encoding/json"

etcd "github.com/coreos/etcd/clientv3"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/setter"
"github.com/mailgun/holster/v3/syncutil"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/setter"
"github.com/mailgun/holster/v4/syncutil"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
etcd "go.etcd.io/etcd/client/v3"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"strings"
"testing"

guber "github.com/mailgun/gubernator"
"github.com/mailgun/gubernator/cluster"
"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/testutil"
guber "github.com/mailgun/gubernator/v2"
"github.com/mailgun/gubernator/v2/cluster"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/testutil"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
Expand Down
4 changes: 2 additions & 2 deletions global.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"context"
"time"

"github.com/mailgun/holster/v3/clock"
"github.com/mailgun/holster/v3/syncutil"
"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/syncutil"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
)
Expand Down
30 changes: 17 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
module github.com/mailgun/gubernator
module github.com/mailgun/gubernator/v2

go 1.14

require (
github.com/coreos/etcd v3.3.15+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/golang/protobuf v1.3.2
github.com/grpc-ecosystem/grpc-gateway v1.11.1
github.com/hashicorp/memberlist v0.2.0
github.com/mailgun/holster/v3 v3.14.0
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/memberlist v0.2.4
github.com/mailgun/holster/v4 v4.0.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.26.0
github.com/segmentio/fasthash v1.0.2
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20190923162816-aa69164e4478
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
google.golang.org/grpc v1.23.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
go.etcd.io/etcd/client/v3 v3.5.0
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1 // indirect
google.golang.org/api v0.30.0
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.27.1 // indirect
k8s.io/api v0.0.0-20190620084959-7cf5895f2711
k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
Expand Down
Loading

0 comments on commit cc98f3a

Please sign in to comment.