Просмотр исходного кода

allow TimeoutLimit to be changed globally

Chris Bannister 10 лет назад
Родитель
Сommit
b21c5b0c28
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      conn.go

+ 3 - 2
conn.go

@@ -86,7 +86,8 @@ type ConnErrorHandler interface {
 // How many timeouts we will allow to occur before the connection is closed
 // How many timeouts we will allow to occur before the connection is closed
 // and restarted. This is to prevent a single query timeout from killing a connection
 // and restarted. This is to prevent a single query timeout from killing a connection
 // which may be serving more queries just fine.
 // which may be serving more queries just fine.
-const timeoutLimit = 10
+// Default is 10, should not be changed concurrently with queries.
+var TimeoutLimit int64 = 10
 
 
 // Conn is a single connection to a Cassandra node. It can be used to execute
 // Conn is a single connection to a Cassandra node. It can be used to execute
 // queries, but users are usually advised to use a more reliable, higher
 // queries, but users are usually advised to use a more reliable, higher
@@ -377,7 +378,7 @@ func (c *Conn) releaseStream(stream int) {
 }
 }
 
 
 func (c *Conn) handleTimeout() {
 func (c *Conn) handleTimeout() {
-	if atomic.AddInt64(&c.timeouts, 1) > timeoutLimit {
+	if atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
 		c.closeWithError(ErrTooManyTimeouts)
 		c.closeWithError(ErrTooManyTimeouts)
 	}
 	}
 }
 }