From 12c19e08b70e0c9346ddddbdc70be301d11c0954 Mon Sep 17 00:00:00 2001 From: Alex Barlow Date: Sat, 19 Mar 2016 21:36:47 +0000 Subject: [PATCH] Add support for Cassandra >= 3 with protocol version 4 --- driver/cassandra/cassandra.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/driver/cassandra/cassandra.go b/driver/cassandra/cassandra.go index faea2a2..e242de2 100644 --- a/driver/cassandra/cassandra.go +++ b/driver/cassandra/cassandra.go @@ -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()