Skip to content

Commit 7e10c93

Browse files
Merge remote-tracking branch 'gocql/master' 1.6.0
2 parents 61be561 + 34fdeeb commit 7e10c93

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

cluster.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,28 @@ type ClusterConfig struct {
5151
// versions the protocol selected is not defined (ie, it can be any of the supported in the cluster)
5252
ProtoVersion int
5353

54-
// Connection timeout (default: 600ms)
54+
// Timeout limits the time spent on the client side while executing a query.
55+
// Specifically, query or batch execution will return an error if the client does not receive a response
56+
// from the server within the Timeout period.
57+
// Timeout is also used to configure the read timeout on the underlying network connection.
58+
// Client Timeout should always be higher than the request timeouts configured on the server,
59+
// so that retries don't overload the server.
60+
// Timeout has a default value of 11 seconds, which is higher than default server timeout for most query types.
61+
// Timeout is not applied to requests during initial connection setup, see ConnectTimeout.
5562
Timeout time.Duration
5663

57-
// Initial connection timeout, used during initial dial to server (default: 600ms)
58-
// ConnectTimeout is used to set up the default dialer and is ignored if Dialer or HostDialer is provided.
64+
// ConnectTimeout limits the time spent during connection setup.
65+
// During initial connection setup, internal queries, AUTH requests will return an error if the client
66+
// does not receive a response within the ConnectTimeout period.
67+
// ConnectTimeout is applied to the connection setup queries independently.
68+
// ConnectTimeout also limits the duration of dialing a new TCP connection
69+
// in case there is no Dialer nor HostDialer configured.
70+
// ConnectTimeout has a default value of 11 seconds.
5971
ConnectTimeout time.Duration
6072

61-
// Timeout for writing a query. Defaults to Timeout if not specified.
73+
// WriteTimeout limits the time the driver waits to write a request to a network connection.
74+
// WriteTimeout should be lower than or equal to Timeout.
75+
// WriteTimeout defaults to the value of Timeout.
6276
WriteTimeout time.Duration
6377

6478
// Port used when dialing.
@@ -263,8 +277,8 @@ func NewCluster(hosts ...string) *ClusterConfig {
263277
cfg := &ClusterConfig{
264278
Hosts: hosts,
265279
CQLVersion: "3.0.0",
266-
Timeout: 600 * time.Millisecond,
267-
ConnectTimeout: 600 * time.Millisecond,
280+
Timeout: 11 * time.Second,
281+
ConnectTimeout: 11 * time.Second,
268282
Port: 9042,
269283
NumConns: 2,
270284
Consistency: Quorum,

cluster_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func TestNewCluster_Defaults(t *testing.T) {
1111
cfg := NewCluster()
1212
assertEqual(t, "cluster config cql version", "3.0.0", cfg.CQLVersion)
13-
assertEqual(t, "cluster config timeout", 600*time.Millisecond, cfg.Timeout)
13+
assertEqual(t, "cluster config timeout", 11*time.Second, cfg.Timeout)
1414
assertEqual(t, "cluster config port", 9042, cfg.Port)
1515
assertEqual(t, "cluster config num-conns", 2, cfg.NumConns)
1616
assertEqual(t, "cluster config consistency", Quorum, cfg.Consistency)

conn_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func TestStartupTimeout(t *testing.T) {
229229
// Set very long query connection timeout
230230
// so we know CreateSession() is using the ConnectTimeout
231231
cluster.Timeout = time.Second * 5
232+
cluster.ConnectTimeout = 600 * time.Millisecond
232233

233234
// Create session should timeout during connect attempt
234235
_, err := cluster.CreateSession()

0 commit comments

Comments
 (0)