mirror of https://github.com/status-im/migrate.git
Add support for Cassandra >= 3 with protocol version 4
This commit is contained in:
parent
5593c9892b
commit
12c19e08b7
|
@ -4,6 +4,7 @@ package cassandra
|
|||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -40,10 +41,10 @@ const (
|
|||
)
|
||||
|
||||
// Cassandra Driver URL format:
|
||||
// cassandra://host:port/keyspace
|
||||
// cassandra://host:port/keyspace?protocol=version
|
||||
//
|
||||
// Example:
|
||||
// cassandra://localhost/SpaceOfKeys
|
||||
// cassandra://localhost/SpaceOfKeys?protocol=4
|
||||
func (driver *Driver) Initialize(rawurl string) error {
|
||||
u, err := url.Parse(rawurl)
|
||||
|
||||
|
@ -52,6 +53,15 @@ func (driver *Driver) Initialize(rawurl string) error {
|
|||
cluster.Consistency = gocql.All
|
||||
cluster.Timeout = 1 * time.Minute
|
||||
|
||||
if len(u.Query().Get("protocol")) > 0 {
|
||||
protoversion, err := strconv.Atoi(u.Query().Get("protocol"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cluster.ProtoVersion = protoversion
|
||||
}
|
||||
|
||||
// Check if url user struct is null
|
||||
if u.User != nil {
|
||||
password, passwordSet := u.User.Password()
|
||||
|
|
Loading…
Reference in New Issue