Skip to content

Commit 2557fa1

Browse files
authored
Add a flag to control Cassandra consistency level (#700)
Signed-off-by: Yuri Shkuro <ys@uber.com>
1 parent 2ad1e59 commit 2557fa1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

plugin/storage/cassandra/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333
suffixServers = ".servers"
3434
suffixPort = ".port"
3535
suffixKeyspace = ".keyspace"
36+
suffixConsistency = ".consistency"
3637
suffixProtoVer = ".proto-version"
3738
suffixSocketKeepAlive = ".socket-keep-alive"
3839
suffixUsername = ".username"
@@ -147,6 +148,10 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
147148
nsConfig.namespace+suffixKeyspace,
148149
nsConfig.Keyspace,
149150
"The Cassandra keyspace for Jaeger data")
151+
flagSet.String(
152+
nsConfig.namespace+suffixConsistency,
153+
nsConfig.Consistency,
154+
"The Cassandra consistency level, e.g. ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM, EACH_QUORUM, LOCAL_ONE (default LOCAL_ONE)")
150155
flagSet.Int(
151156
nsConfig.namespace+suffixProtoVer,
152157
nsConfig.ProtoVersion,
@@ -209,6 +214,7 @@ func (cfg *namespaceConfig) initFromViper(v *viper.Viper) {
209214
cfg.servers = v.GetString(cfg.namespace + suffixServers)
210215
cfg.Port = v.GetInt(cfg.namespace + suffixPort)
211216
cfg.Keyspace = v.GetString(cfg.namespace + suffixKeyspace)
217+
cfg.Consistency = v.GetString(cfg.namespace + suffixConsistency)
212218
cfg.ProtoVersion = v.GetInt(cfg.namespace + suffixProtoVer)
213219
cfg.SocketKeepAlive = v.GetDuration(cfg.namespace + suffixSocketKeepAlive)
214220
cfg.Authenticator.Basic.Username = v.GetString(cfg.namespace + suffixUsername)

plugin/storage/cassandra/options_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func TestOptionsWithFlags(t *testing.T) {
5353
"--cas.max-retry-attempts=42",
5454
"--cas.timeout=42s",
5555
"--cas.port=4242",
56+
"--cas.consistency=ONE",
5657
"--cas.proto-version=3",
5758
"--cas.socket-keep-alive=42s",
5859
// enable aux with a couple overrides
@@ -65,6 +66,7 @@ func TestOptionsWithFlags(t *testing.T) {
6566
primary := opts.GetPrimary()
6667
assert.Equal(t, "jaeger", primary.Keyspace)
6768
assert.Equal(t, []string{"1.1.1.1", "2.2.2.2"}, primary.Servers)
69+
assert.Equal(t, "ONE", primary.Consistency)
6870

6971
aux := opts.Get("cas-aux")
7072
require.NotNil(t, aux)
@@ -74,6 +76,7 @@ func TestOptionsWithFlags(t *testing.T) {
7476
assert.Equal(t, 42, aux.MaxRetryAttempts)
7577
assert.Equal(t, 42*time.Second, aux.Timeout)
7678
assert.Equal(t, 4242, aux.Port)
79+
assert.Equal(t, "", aux.Consistency, "aux storage does not inherit consistency from primary")
7780
assert.Equal(t, 3, aux.ProtoVersion)
7881
assert.Equal(t, 42*time.Second, aux.SocketKeepAlive)
7982
}

0 commit comments

Comments
 (0)