Skip to content
This repository was archived by the owner on Jun 28, 2018. It is now read-only.

Commit ce1b59b

Browse files
committed
Merge pull request #89 from arbarlow/master
Add support for Cassandra >= 3 with protocol version 4
2 parents 5593c98 + 12c19e0 commit ce1b59b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

driver/cassandra/cassandra.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package cassandra
44
import (
55
"fmt"
66
"net/url"
7+
"strconv"
78
"strings"
89
"time"
910

@@ -40,10 +41,10 @@ const (
4041
)
4142

4243
// Cassandra Driver URL format:
43-
// cassandra://host:port/keyspace
44+
// cassandra://host:port/keyspace?protocol=version
4445
//
4546
// Example:
46-
// cassandra://localhost/SpaceOfKeys
47+
// cassandra://localhost/SpaceOfKeys?protocol=4
4748
func (driver *Driver) Initialize(rawurl string) error {
4849
u, err := url.Parse(rawurl)
4950

@@ -52,6 +53,15 @@ func (driver *Driver) Initialize(rawurl string) error {
5253
cluster.Consistency = gocql.All
5354
cluster.Timeout = 1 * time.Minute
5455

56+
if len(u.Query().Get("protocol")) > 0 {
57+
protoversion, err := strconv.Atoi(u.Query().Get("protocol"))
58+
if err != nil {
59+
return err
60+
}
61+
62+
cluster.ProtoVersion = protoversion
63+
}
64+
5565
// Check if url user struct is null
5666
if u.User != nil {
5767
password, passwordSet := u.User.Password()

0 commit comments

Comments
 (0)