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

Commit 1921376

Browse files
committed
Update CHANGELOG and improved errors when using GUBER_PEER_PICKER
1 parent ceed75f commit 1921376

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.9.1] - 2020-10-19
8+
### Change
9+
* Fix GUBER_PEER_PICKER_HASH and GUBER_PEER_PICKER
10+
* Now warns if GUBER_PEER_PICKER value is incorrect
11+
* Now ignoring spaces between `key = value` in config file
12+
713
## [0.9.0] - 2020-10-13
814
### Change
915
* Fix GUBER_MEMBERLIST_ADVERTISE_PORT value type

cmd/gubernator/config.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ func confFromEnv() (ServerConfig, error) {
146146
"fnv1": fnv1.HashBytes32,
147147
"crc32": nil,
148148
}
149-
if fn, ok := hashFuncs[hash]; ok {
150-
conf.Picker = gubernator.NewConsistantHash(fn)
151-
return conf, nil
149+
fn, ok := hashFuncs[hash]
150+
if !ok {
151+
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
152+
hash, validHashKeys(hashFuncs))
152153
}
153-
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
154-
hash, validHashKeys(hashFuncs))
154+
conf.Picker = gubernator.NewConsistantHash(fn)
155155

156156
case "replicated-hash":
157157
setter.SetDefault(&replicas, getEnvInteger("GUBER_REPLICATED_HASH_REPLICAS"), 1)
@@ -161,12 +161,14 @@ func confFromEnv() (ServerConfig, error) {
161161
"fnv1a": fnv1a.HashBytes64,
162162
"fnv1": fnv1.HashBytes64,
163163
}
164-
if fn, ok := hashFuncs[hash]; ok {
165-
conf.Picker = gubernator.NewReplicatedConsistantHash(fn, replicas)
166-
return conf, nil
164+
fn, ok := hashFuncs[hash]
165+
if !ok {
166+
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
167+
hash, validHash64Keys(hashFuncs))
167168
}
168-
return conf, errors.Errorf("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]",
169-
hash, validHash64Keys(hashFuncs))
169+
conf.Picker = gubernator.NewReplicatedConsistantHash(fn, replicas)
170+
default:
171+
return conf, errors.Errorf("'GUBER_PEER_PICKER=%s' is invalid; choices are ['replicated-hash', 'consistent-hash']", pp)
170172
}
171173
}
172174

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

331-
if err := os.Setenv(parts[0], parts[1]); err != nil {
333+
if err := os.Setenv(strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])); err != nil {
332334
return errors.Wrapf(err, "while settings environ for '%s=%s'", parts[0], parts[1])
333335
}
334336
}

example.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ GUBER_ETCD_ADVERTISE_ADDRESS=localhost:81
100100
# GUBER_PEER_PICKER=consistent-hash
101101

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

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

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

111111
# Choose the number of replications
112-
# GUBER_REPLICATED_HASH_REPLICAS = 1
112+
# GUBER_REPLICATED_HASH_REPLICAS=1
113113

0 commit comments

Comments
 (0)