Skip to content

Commit e1d604b

Browse files
authored
Merge pull request #708 from taywrobel/cassandra-connect-timeout
Expose configuring cassandra connect timeout through query string
2 parents 0bc9734 + 6e499cb commit e1d604b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

database/cassandra/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ system_schema table which comes with 3.X
2020
| `consistency` | ALL | Migration consistency
2121
| `protocol` | | Cassandra protocol version (3 or 4)
2222
| `timeout` | 1 minute | Migration timeout
23+
| `connect-timeout` | 600ms | Initial connection timeout to the cluster |
2324
| `username` | nil | Username to use when authenticating. |
2425
| `password` | nil | Password to use when authenticating. |
2526
| `sslcert` | | Cert file location. The file must contain PEM encoded data. |

database/cassandra/cassandra.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ func (c *Cassandra) Open(url string) (database.Driver, error) {
133133
}
134134
cluster.Timeout = timeout
135135
}
136+
if len(u.Query().Get("connect-timeout")) > 0 {
137+
var connectTimeout time.Duration
138+
connectTimeout, err = time.ParseDuration(u.Query().Get("connect-timeout"))
139+
if err != nil {
140+
return nil, err
141+
}
142+
cluster.ConnectTimeout = connectTimeout
143+
}
136144

137145
if len(u.Query().Get("sslmode")) > 0 {
138146
if u.Query().Get("sslmode") != "disable" {

0 commit comments

Comments
 (0)