Skip to content

Commit 9ce397a

Browse files
tomwilkiebboreham
authored andcommitted
Comma-separated addresses for cassandra. (#770)
1 parent 864c53a commit 9ce397a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/chunk/cassandra/storage_client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"flag"
66
"fmt"
7+
"strings"
78
"time"
89

910
"github.com/gocql/gocql"
@@ -17,15 +18,15 @@ const (
1718

1819
// Config for a StorageClient
1920
type Config struct {
20-
address string
21+
addresses string
2122
keyspace string
2223
consistency string
2324
replicationFactor int
2425
}
2526

2627
// RegisterFlags adds the flags required to config this to the given FlagSet
2728
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
28-
f.StringVar(&cfg.address, "cassandra.address", "", "Address of Cassandra instances.")
29+
f.StringVar(&cfg.addresses, "cassandra.addresses", "", "Comma-separated addresses of Cassandra instances.")
2930
f.StringVar(&cfg.keyspace, "cassandra.keyspace", "", "Keyspace to use in Cassandra.")
3031
f.StringVar(&cfg.consistency, "cassandra.consistency", "QUORUM", "Consistency level for Cassandra.")
3132
f.IntVar(&cfg.replicationFactor, "cassandra.replication-factor", 1, "Replication factor to use in Cassandra.")
@@ -41,7 +42,7 @@ func (cfg *Config) session() (*gocql.Session, error) {
4142
return nil, err
4243
}
4344

44-
cluster := gocql.NewCluster(cfg.address)
45+
cluster := gocql.NewCluster(strings.Split(cfg.addresses, ",")...)
4546
cluster.Keyspace = cfg.keyspace
4647
cluster.Consistency = consistency
4748
cluster.BatchObserver = observer{}
@@ -52,7 +53,7 @@ func (cfg *Config) session() (*gocql.Session, error) {
5253

5354
// createKeyspace will create the desired keyspace if it doesn't exist.
5455
func (cfg *Config) createKeyspace() error {
55-
cluster := gocql.NewCluster(cfg.address)
56+
cluster := gocql.NewCluster(strings.Split(cfg.addresses, ",")...)
5657
cluster.Keyspace = "system"
5758
cluster.Timeout = 20 * time.Second
5859
session, err := cluster.CreateSession()

0 commit comments

Comments
 (0)