Browse Source
Merge pull request #1490 from hilimd/master
Add cassandra authenticator mode
pull/1502/head
Chris Lu
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
weed/filer/cassandra/cassandra_store.go
|
|
@ -28,11 +28,16 @@ func (store *CassandraStore) Initialize(configuration util.Configuration, prefix |
|
|
|
return store.initialize( |
|
|
|
configuration.GetString(prefix+"keyspace"), |
|
|
|
configuration.GetStringSlice(prefix+"hosts"), |
|
|
|
configuration.GetString(prefix+"username"), |
|
|
|
configuration.GetString(prefix+"password"), |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
func (store *CassandraStore) initialize(keyspace string, hosts []string) (err error) { |
|
|
|
func (store *CassandraStore) initialize(keyspace string, hosts []string, username string, password string) (err error) { |
|
|
|
store.cluster = gocql.NewCluster(hosts...) |
|
|
|
if username != "" && password != "" { |
|
|
|
store.cluster.Authenticator = gocql.PasswordAuthenticator{Username: username, Password: password} |
|
|
|
} |
|
|
|
store.cluster.Keyspace = keyspace |
|
|
|
store.cluster.Consistency = gocql.LocalQuorum |
|
|
|
store.session, err = store.cluster.CreateSession() |
|
|
|