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

Commit

Permalink
Update CHANGELOG and improved errors when using GUBER_PEER_PICKER
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Oct 19, 2020
1 parent ceed75f commit 1921376
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.1] - 2020-10-19
### Change
* Fix GUBER_PEER_PICKER_HASH and GUBER_PEER_PICKER
* Now warns if GUBER_PEER_PICKER value is incorrect
* Now ignoring spaces between `key = value` in config file

## [0.9.0] - 2020-10-13
### Change
* Fix GUBER_MEMBERLIST_ADVERTISE_PORT value type
Expand Down
24 changes: 13 additions & 11 deletions cmd/gubernator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ func confFromEnv() (ServerConfig, error) {
"fnv1": fnv1.HashBytes32,
"crc32": nil,
}
if fn, ok := hashFuncs[hash]; ok {
conf.Picker = gubernator.NewConsistantHash(fn)
return conf, nil
fn, ok := hashFuncs[hash]
if !ok {
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHashKeys(hashFuncs))
}
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHashKeys(hashFuncs))
conf.Picker = gubernator.NewConsistantHash(fn)

case "replicated-hash":
setter.SetDefault(&replicas, getEnvInteger("GUBER_REPLICATED_HASH_REPLICAS"), 1)
Expand All @@ -161,12 +161,14 @@ func confFromEnv() (ServerConfig, error) {
"fnv1a": fnv1a.HashBytes64,
"fnv1": fnv1.HashBytes64,
}
if fn, ok := hashFuncs[hash]; ok {
conf.Picker = gubernator.NewReplicatedConsistantHash(fn, replicas)
return conf, nil
fn, ok := hashFuncs[hash]
if !ok {
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHash64Keys(hashFuncs))
}
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
hash, validHash64Keys(hashFuncs))
conf.Picker = gubernator.NewReplicatedConsistantHash(fn, replicas)
default:
return conf, errors.Errorf("'GUBER_PEER_PICKER=%s' is invalid; choices are ['replicated-hash', 'consistent-hash']", pp)
}
}

Expand Down Expand Up @@ -328,7 +330,7 @@ func fromEnvFile(configFile string) error {
return errors.Errorf("malformed key=value on line '%d'", i)
}

if err := os.Setenv(parts[0], parts[1]); err != nil {
if err := os.Setenv(strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])); err != nil {
return errors.Wrapf(err, "while settings environ for '%s=%s'", parts[0], parts[1])
}
}
Expand Down
6 changes: 3 additions & 3 deletions example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ GUBER_ETCD_ADVERTISE_ADDRESS=localhost:81
# GUBER_PEER_PICKER=consistent-hash

# Choose the hash algorithm for `consistent-hash` (crc32, fnv1a, fnv1)
# GUBER_PEER_PICKER_HASH = crc32
# GUBER_PEER_PICKER_HASH=crc32

# Choose which picker algorithm to use
# GUBER_PEER_PICKER=replicated-hash

# Choose the hash algorithm for `replicated-hash` (fnv1a, fnv1)
# GUBER_PEER_PICKER_HASH = fnv1a
# GUBER_PEER_PICKER_HASH=fnv1a

# Choose the number of replications
# GUBER_REPLICATED_HASH_REPLICAS = 1
# GUBER_REPLICATED_HASH_REPLICAS=1

0 comments on commit 1921376

Please sign in to comment.