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 #70 from gogorush/master
Browse files Browse the repository at this point in the history
fix GUBER_PEER_PICKER_HASH default value bug
  • Loading branch information
thrawn01 authored Oct 19, 2020
2 parents 7ae5c65 + f6b4b40 commit ceed75f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/gubernator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ func confFromEnv() (ServerConfig, error) {

switch pp {
case "consistent-hash":
setter.SetDefault(&hash, os.Getenv("GUBER_PEER_PICKER_HASH"), "crc32")
setter.SetDefault(&hash, os.Getenv("GUBER_PEER_PICKER_HASH"), "fnv1a")
hashFuncs := map[string]gubernator.HashFunc{
"fnv1a": fnv1a.HashBytes32,
"fnv1": fnv1.HashBytes32,
"crc32": nil,
}
if fn, ok := hashFuncs[hash]; ok {
conf.Picker = gubernator.NewConsistantHash(fn)
return conf, nil
}
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHashKeys(hashFuncs))
Expand All @@ -162,6 +163,7 @@ func confFromEnv() (ServerConfig, error) {
}
if fn, ok := hashFuncs[hash]; ok {
conf.Picker = gubernator.NewReplicatedConsistantHash(fn, replicas)
return conf, nil
}
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHash64Keys(hashFuncs))
Expand Down

0 comments on commit ceed75f

Please sign in to comment.