Skip to content

Commit

Permalink
Merge pull request #708 from taywrobel/cassandra-connect-timeout
Browse files Browse the repository at this point in the history
Expose configuring cassandra connect timeout through query string
  • Loading branch information
dhui committed Feb 22, 2022
2 parents 0bc9734 + 6e499cb commit e1d604b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/cassandra/README.md
Expand Up @@ -20,6 +20,7 @@ system_schema table which comes with 3.X
| `consistency` | ALL | Migration consistency
| `protocol` | | Cassandra protocol version (3 or 4)
| `timeout` | 1 minute | Migration timeout
| `connect-timeout` | 600ms | Initial connection timeout to the cluster |
| `username` | nil | Username to use when authenticating. |
| `password` | nil | Password to use when authenticating. |
| `sslcert` | | Cert file location. The file must contain PEM encoded data. |
Expand Down
8 changes: 8 additions & 0 deletions database/cassandra/cassandra.go
Expand Up @@ -133,6 +133,14 @@ func (c *Cassandra) Open(url string) (database.Driver, error) {
}
cluster.Timeout = timeout
}
if len(u.Query().Get("connect-timeout")) > 0 {
var connectTimeout time.Duration
connectTimeout, err = time.ParseDuration(u.Query().Get("connect-timeout"))
if err != nil {
return nil, err
}
cluster.ConnectTimeout = connectTimeout
}

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

0 comments on commit e1d604b

Please sign in to comment.