Merge pull request #89 from arbarlow/master

Add support for Cassandra >= 3 with protocol version 4
This commit is contained in:
Matthias Kadenbach 2016-03-21 14:09:30 -07:00
commit ce1b59bb81

View File

@ -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()