conn.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. // Copyright (c) 2012 The gocql Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package gocql
  5. import (
  6. "bufio"
  7. "crypto/tls"
  8. "errors"
  9. "fmt"
  10. "io"
  11. "io/ioutil"
  12. "log"
  13. "net"
  14. "strconv"
  15. "strings"
  16. "sync"
  17. "sync/atomic"
  18. "time"
  19. )
  20. //JoinHostPort is a utility to return a address string that can be used
  21. //gocql.Conn to form a connection with a host.
  22. func JoinHostPort(addr string, port int) string {
  23. addr = strings.TrimSpace(addr)
  24. if _, _, err := net.SplitHostPort(addr); err != nil {
  25. addr = net.JoinHostPort(addr, strconv.Itoa(port))
  26. }
  27. return addr
  28. }
  29. type Authenticator interface {
  30. Challenge(req []byte) (resp []byte, auth Authenticator, err error)
  31. Success(data []byte) error
  32. }
  33. type PasswordAuthenticator struct {
  34. Username string
  35. Password string
  36. }
  37. func (p PasswordAuthenticator) Challenge(req []byte) ([]byte, Authenticator, error) {
  38. if string(req) != "org.apache.cassandra.auth.PasswordAuthenticator" {
  39. return nil, nil, fmt.Errorf("unexpected authenticator %q", req)
  40. }
  41. resp := make([]byte, 2+len(p.Username)+len(p.Password))
  42. resp[0] = 0
  43. copy(resp[1:], p.Username)
  44. resp[len(p.Username)+1] = 0
  45. copy(resp[2+len(p.Username):], p.Password)
  46. return resp, nil, nil
  47. }
  48. func (p PasswordAuthenticator) Success(data []byte) error {
  49. return nil
  50. }
  51. type SslOptions struct {
  52. tls.Config
  53. // CertPath and KeyPath are optional depending on server
  54. // config, but both fields must be omitted to avoid using a
  55. // client certificate
  56. CertPath string
  57. KeyPath string
  58. CaPath string //optional depending on server config
  59. // If you want to verify the hostname and server cert (like a wildcard for cass cluster) then you should turn this on
  60. // This option is basically the inverse of InSecureSkipVerify
  61. // See InSecureSkipVerify in http://golang.org/pkg/crypto/tls/ for more info
  62. EnableHostVerification bool
  63. }
  64. type ConnConfig struct {
  65. ProtoVersion int
  66. CQLVersion string
  67. Timeout time.Duration
  68. NumStreams int
  69. Compressor Compressor
  70. Authenticator Authenticator
  71. Keepalive time.Duration
  72. tlsConfig *tls.Config
  73. }
  74. type ConnErrorHandler interface {
  75. HandleError(conn *Conn, err error, closed bool)
  76. }
  77. // How many timeouts we will allow to occur before the connection is closed
  78. // and restarted. This is to prevent a single query timeout from killing a connection
  79. // which may be serving more queries just fine.
  80. // Default is 10, should not be changed concurrently with queries.
  81. var TimeoutLimit int64 = 10
  82. // Conn is a single connection to a Cassandra node. It can be used to execute
  83. // queries, but users are usually advised to use a more reliable, higher
  84. // level API.
  85. type Conn struct {
  86. conn net.Conn
  87. r *bufio.Reader
  88. timeout time.Duration
  89. headerBuf []byte
  90. uniq chan int
  91. calls []callReq
  92. errorHandler ConnErrorHandler
  93. compressor Compressor
  94. auth Authenticator
  95. addr string
  96. version uint8
  97. currentKeyspace string
  98. started bool
  99. closed int32
  100. quit chan struct{}
  101. timeouts int64
  102. }
  103. // Connect establishes a connection to a Cassandra node.
  104. // You must also call the Serve method before you can execute any queries.
  105. func Connect(addr string, cfg ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) {
  106. var (
  107. err error
  108. conn net.Conn
  109. )
  110. dialer := &net.Dialer{
  111. Timeout: cfg.Timeout,
  112. }
  113. if cfg.tlsConfig != nil {
  114. // the TLS config is safe to be reused by connections but it must not
  115. // be modified after being used.
  116. conn, err = tls.DialWithDialer(dialer, "tcp", addr, cfg.tlsConfig)
  117. } else {
  118. conn, err = dialer.Dial("tcp", addr)
  119. }
  120. if err != nil {
  121. return nil, err
  122. }
  123. // going to default to proto 2
  124. if cfg.ProtoVersion < protoVersion1 || cfg.ProtoVersion > protoVersion3 {
  125. log.Printf("unsupported protocol version: %d using 2\n", cfg.ProtoVersion)
  126. cfg.ProtoVersion = 2
  127. }
  128. headerSize := 8
  129. maxStreams := 128
  130. if cfg.ProtoVersion > protoVersion2 {
  131. maxStreams = 32768
  132. headerSize = 9
  133. }
  134. if cfg.NumStreams <= 0 || cfg.NumStreams > maxStreams {
  135. cfg.NumStreams = maxStreams
  136. }
  137. c := &Conn{
  138. conn: conn,
  139. r: bufio.NewReader(conn),
  140. uniq: make(chan int, cfg.NumStreams),
  141. calls: make([]callReq, cfg.NumStreams),
  142. timeout: cfg.Timeout,
  143. version: uint8(cfg.ProtoVersion),
  144. addr: conn.RemoteAddr().String(),
  145. errorHandler: errorHandler,
  146. compressor: cfg.Compressor,
  147. auth: cfg.Authenticator,
  148. headerBuf: make([]byte, headerSize),
  149. quit: make(chan struct{}),
  150. }
  151. if cfg.Keepalive > 0 {
  152. c.setKeepalive(cfg.Keepalive)
  153. }
  154. for i := 0; i < cfg.NumStreams; i++ {
  155. c.calls[i].resp = make(chan error)
  156. c.uniq <- i
  157. }
  158. go c.serve()
  159. if err := c.startup(&cfg); err != nil {
  160. conn.Close()
  161. return nil, err
  162. }
  163. c.started = true
  164. return c, nil
  165. }
  166. func (c *Conn) Write(p []byte) (int, error) {
  167. if c.timeout > 0 {
  168. c.conn.SetWriteDeadline(time.Now().Add(c.timeout))
  169. }
  170. return c.conn.Write(p)
  171. }
  172. func (c *Conn) Read(p []byte) (n int, err error) {
  173. const maxAttempts = 5
  174. for i := 0; i < maxAttempts; i++ {
  175. var nn int
  176. if c.timeout > 0 {
  177. c.conn.SetReadDeadline(time.Now().Add(c.timeout))
  178. }
  179. nn, err = io.ReadFull(c.r, p[n:])
  180. n += nn
  181. if err == nil {
  182. break
  183. }
  184. if verr, ok := err.(net.Error); !ok || !verr.Temporary() {
  185. break
  186. }
  187. }
  188. return
  189. }
  190. func (c *Conn) startup(cfg *ConnConfig) error {
  191. m := map[string]string{
  192. "CQL_VERSION": cfg.CQLVersion,
  193. }
  194. if c.compressor != nil {
  195. m["COMPRESSION"] = c.compressor.Name()
  196. }
  197. frame, err := c.exec(&writeStartupFrame{opts: m}, nil)
  198. if err != nil {
  199. return err
  200. }
  201. switch v := frame.(type) {
  202. case error:
  203. return v
  204. case *readyFrame:
  205. return nil
  206. case *authenticateFrame:
  207. return c.authenticateHandshake(v)
  208. default:
  209. return NewErrProtocol("Unknown type of response to startup frame: %s", v)
  210. }
  211. }
  212. func (c *Conn) authenticateHandshake(authFrame *authenticateFrame) error {
  213. if c.auth == nil {
  214. return fmt.Errorf("authentication required (using %q)", authFrame.class)
  215. }
  216. resp, challenger, err := c.auth.Challenge([]byte(authFrame.class))
  217. if err != nil {
  218. return err
  219. }
  220. req := &writeAuthResponseFrame{data: resp}
  221. for {
  222. frame, err := c.exec(req, nil)
  223. if err != nil {
  224. return err
  225. }
  226. switch v := frame.(type) {
  227. case error:
  228. return v
  229. case *authSuccessFrame:
  230. if challenger != nil {
  231. return challenger.Success(v.data)
  232. }
  233. return nil
  234. case *authChallengeFrame:
  235. resp, challenger, err = challenger.Challenge(v.data)
  236. if err != nil {
  237. return err
  238. }
  239. req = &writeAuthResponseFrame{
  240. data: resp,
  241. }
  242. default:
  243. return fmt.Errorf("unknown frame response during authentication: %v", v)
  244. }
  245. }
  246. }
  247. func (c *Conn) closeWithError(err error) {
  248. if !atomic.CompareAndSwapInt32(&c.closed, 0, 1) {
  249. return
  250. }
  251. if err != nil {
  252. // we should attempt to deliver the error back to the caller if it
  253. // exists
  254. for id := 0; id < len(c.calls); id++ {
  255. req := &c.calls[id]
  256. // we need to send the error to all waiting queries, put the state
  257. // of this conn into not active so that it can not execute any queries.
  258. if err != nil {
  259. select {
  260. case req.resp <- err:
  261. default:
  262. }
  263. }
  264. }
  265. }
  266. // if error was nil then unblock the quit channel
  267. close(c.quit)
  268. c.conn.Close()
  269. if c.started && err != nil {
  270. c.errorHandler.HandleError(c, err, true)
  271. }
  272. }
  273. func (c *Conn) Close() {
  274. c.closeWithError(nil)
  275. }
  276. // Serve starts the stream multiplexer for this connection, which is required
  277. // to execute any queries. This method runs as long as the connection is
  278. // open and is therefore usually called in a separate goroutine.
  279. func (c *Conn) serve() {
  280. var (
  281. err error
  282. )
  283. for {
  284. err = c.recv()
  285. if err != nil {
  286. break
  287. }
  288. }
  289. c.closeWithError(err)
  290. }
  291. func (c *Conn) recv() error {
  292. // not safe for concurrent reads
  293. // read a full header, ignore timeouts, as this is being ran in a loop
  294. // TODO: TCP level deadlines? or just query level deadlines?
  295. if c.timeout > 0 {
  296. c.conn.SetReadDeadline(time.Time{})
  297. }
  298. // were just reading headers over and over and copy bodies
  299. head, err := readHeader(c.r, c.headerBuf)
  300. if err != nil {
  301. return err
  302. }
  303. if head.stream > len(c.calls) {
  304. return fmt.Errorf("gocql: frame header stream is beyond call exepected bounds: %d", head.stream)
  305. } else if head.stream < 0 {
  306. // TODO: handle cassandra event frames, we shouldnt get any currently
  307. _, err := io.CopyN(ioutil.Discard, c, int64(head.length))
  308. if err != nil {
  309. return err
  310. }
  311. return nil
  312. }
  313. call := &c.calls[head.stream]
  314. err = call.framer.readFrame(&head)
  315. if err != nil {
  316. // only net errors should cause the connection to be closed. Though
  317. // cassandra returning corrupt frames will be returned here as well.
  318. if _, ok := err.(net.Error); ok {
  319. return err
  320. }
  321. }
  322. // we either, return a response to the caller, the caller timedout, or the
  323. // connection has closed. Either way we should never block indefinatly here
  324. select {
  325. case call.resp <- err:
  326. case <-call.timeout:
  327. c.releaseStream(head.stream)
  328. case <-c.quit:
  329. }
  330. return nil
  331. }
  332. type callReq struct {
  333. // could use a waitgroup but this allows us to do timeouts on the read/send
  334. resp chan error
  335. framer *framer
  336. timeout chan struct{} // indicates to recv() that a call has timedout
  337. }
  338. func (c *Conn) releaseStream(stream int) {
  339. call := &c.calls[stream]
  340. framerPool.Put(call.framer)
  341. call.framer = nil
  342. select {
  343. case c.uniq <- stream:
  344. case <-c.quit:
  345. }
  346. }
  347. func (c *Conn) handleTimeout() {
  348. if atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
  349. c.closeWithError(ErrTooManyTimeouts)
  350. }
  351. }
  352. func (c *Conn) exec(req frameWriter, tracer Tracer) (frame, error) {
  353. // TODO: move tracer onto conn
  354. var stream int
  355. select {
  356. case stream = <-c.uniq:
  357. case <-c.quit:
  358. return nil, ErrConnectionClosed
  359. }
  360. // resp is basically a waiting semaphore protecting the framer
  361. framer := newFramer(c, c, c.compressor, c.version)
  362. call := &c.calls[stream]
  363. call.framer = framer
  364. call.timeout = make(chan struct{})
  365. if tracer != nil {
  366. framer.trace()
  367. }
  368. err := req.writeFrame(framer, stream)
  369. if err != nil {
  370. return nil, err
  371. }
  372. select {
  373. case err := <-call.resp:
  374. // dont release the stream if detect a timeout as another request can reuse
  375. // that stream and get a response for the old request, which we have no
  376. // easy way of detecting.
  377. defer c.releaseStream(stream)
  378. if err != nil {
  379. return nil, err
  380. }
  381. case <-time.After(c.timeout):
  382. close(call.timeout)
  383. c.handleTimeout()
  384. return nil, ErrTimeoutNoResponse
  385. case <-c.quit:
  386. return nil, ErrConnectionClosed
  387. }
  388. if v := framer.header.version.version(); v != c.version {
  389. return nil, NewErrProtocol("unexpected protocol version in response: got %d expected %d", v, c.version)
  390. }
  391. frame, err := framer.parseFrame()
  392. if err != nil {
  393. return nil, err
  394. }
  395. if len(framer.traceID) > 0 {
  396. tracer.Trace(framer.traceID)
  397. }
  398. return frame, nil
  399. }
  400. func (c *Conn) prepareStatement(stmt string, trace Tracer) (*resultPreparedFrame, error) {
  401. stmtsLRU.Lock()
  402. if stmtsLRU.lru == nil {
  403. initStmtsLRU(defaultMaxPreparedStmts)
  404. }
  405. stmtCacheKey := c.addr + c.currentKeyspace + stmt
  406. if val, ok := stmtsLRU.lru.Get(stmtCacheKey); ok {
  407. stmtsLRU.Unlock()
  408. flight := val.(*inflightPrepare)
  409. flight.wg.Wait()
  410. return flight.info, flight.err
  411. }
  412. flight := new(inflightPrepare)
  413. flight.wg.Add(1)
  414. stmtsLRU.lru.Add(stmtCacheKey, flight)
  415. stmtsLRU.Unlock()
  416. prep := &writePrepareFrame{
  417. statement: stmt,
  418. }
  419. resp, err := c.exec(prep, trace)
  420. if err != nil {
  421. flight.err = err
  422. flight.wg.Done()
  423. return nil, err
  424. }
  425. switch x := resp.(type) {
  426. case *resultPreparedFrame:
  427. flight.info = x
  428. case error:
  429. flight.err = x
  430. default:
  431. flight.err = NewErrProtocol("Unknown type in response to prepare frame: %s", x)
  432. }
  433. flight.wg.Done()
  434. if flight.err != nil {
  435. stmtsLRU.Lock()
  436. stmtsLRU.lru.Remove(stmtCacheKey)
  437. stmtsLRU.Unlock()
  438. }
  439. return flight.info, flight.err
  440. }
  441. func (c *Conn) executeQuery(qry *Query) *Iter {
  442. params := queryParams{
  443. consistency: qry.cons,
  444. }
  445. // frame checks that it is not 0
  446. params.serialConsistency = qry.serialCons
  447. params.defaultTimestamp = qry.defaultTimestamp
  448. if len(qry.pageState) > 0 {
  449. params.pagingState = qry.pageState
  450. }
  451. if qry.pageSize > 0 {
  452. params.pageSize = qry.pageSize
  453. }
  454. var frame frameWriter
  455. if qry.shouldPrepare() {
  456. // Prepare all DML queries. Other queries can not be prepared.
  457. info, err := c.prepareStatement(qry.stmt, qry.trace)
  458. if err != nil {
  459. return &Iter{err: err}
  460. }
  461. var values []interface{}
  462. if qry.binding == nil {
  463. values = qry.values
  464. } else {
  465. binding := &QueryInfo{
  466. Id: info.preparedID,
  467. Args: info.reqMeta.columns,
  468. Rval: info.respMeta.columns,
  469. }
  470. values, err = qry.binding(binding)
  471. if err != nil {
  472. return &Iter{err: err}
  473. }
  474. }
  475. if len(values) != len(info.reqMeta.columns) {
  476. return &Iter{err: ErrQueryArgLength}
  477. }
  478. params.values = make([]queryValues, len(values))
  479. for i := 0; i < len(values); i++ {
  480. val, err := Marshal(info.reqMeta.columns[i].TypeInfo, values[i])
  481. if err != nil {
  482. return &Iter{err: err}
  483. }
  484. v := &params.values[i]
  485. v.value = val
  486. // TODO: handle query binding names
  487. }
  488. frame = &writeExecuteFrame{
  489. preparedID: info.preparedID,
  490. params: params,
  491. }
  492. } else {
  493. frame = &writeQueryFrame{
  494. statement: qry.stmt,
  495. params: params,
  496. }
  497. }
  498. resp, err := c.exec(frame, qry.trace)
  499. if err != nil {
  500. return &Iter{err: err}
  501. }
  502. switch x := resp.(type) {
  503. case *resultVoidFrame:
  504. return &Iter{}
  505. case *resultRowsFrame:
  506. iter := &Iter{
  507. meta: x.meta,
  508. rows: x.rows,
  509. }
  510. if len(x.meta.pagingState) > 0 {
  511. iter.next = &nextIter{
  512. qry: *qry,
  513. pos: int((1 - qry.prefetch) * float64(len(iter.rows))),
  514. }
  515. iter.next.qry.pageState = x.meta.pagingState
  516. if iter.next.pos < 1 {
  517. iter.next.pos = 1
  518. }
  519. }
  520. return iter
  521. case *resultKeyspaceFrame, *resultSchemaChangeFrame:
  522. return &Iter{}
  523. case *RequestErrUnprepared:
  524. stmtsLRU.Lock()
  525. stmtCacheKey := c.addr + c.currentKeyspace + qry.stmt
  526. if _, ok := stmtsLRU.lru.Get(stmtCacheKey); ok {
  527. stmtsLRU.lru.Remove(stmtCacheKey)
  528. stmtsLRU.Unlock()
  529. return c.executeQuery(qry)
  530. }
  531. stmtsLRU.Unlock()
  532. return &Iter{err: x}
  533. case error:
  534. return &Iter{err: x}
  535. default:
  536. return &Iter{err: NewErrProtocol("Unknown type in response to execute query: %s", x)}
  537. }
  538. }
  539. func (c *Conn) Pick(qry *Query) *Conn {
  540. if c.Closed() {
  541. return nil
  542. }
  543. return c
  544. }
  545. func (c *Conn) Closed() bool {
  546. return atomic.LoadInt32(&c.closed) == 1
  547. }
  548. func (c *Conn) Address() string {
  549. return c.addr
  550. }
  551. func (c *Conn) AvailableStreams() int {
  552. return len(c.uniq)
  553. }
  554. func (c *Conn) UseKeyspace(keyspace string) error {
  555. q := &writeQueryFrame{statement: `USE "` + keyspace + `"`}
  556. q.params.consistency = Any
  557. resp, err := c.exec(q, nil)
  558. if err != nil {
  559. return err
  560. }
  561. switch x := resp.(type) {
  562. case *resultKeyspaceFrame:
  563. case error:
  564. return x
  565. default:
  566. return NewErrProtocol("unknown frame in response to USE: %v", x)
  567. }
  568. c.currentKeyspace = keyspace
  569. return nil
  570. }
  571. func (c *Conn) executeBatch(batch *Batch) error {
  572. if c.version == protoVersion1 {
  573. return ErrUnsupported
  574. }
  575. n := len(batch.Entries)
  576. req := &writeBatchFrame{
  577. typ: batch.Type,
  578. statements: make([]batchStatment, n),
  579. consistency: batch.Cons,
  580. serialConsistency: batch.serialCons,
  581. defaultTimestamp: batch.defaultTimestamp,
  582. }
  583. stmts := make(map[string]string)
  584. for i := 0; i < n; i++ {
  585. entry := &batch.Entries[i]
  586. b := &req.statements[i]
  587. if len(entry.Args) > 0 || entry.binding != nil {
  588. info, err := c.prepareStatement(entry.Stmt, nil)
  589. if err != nil {
  590. return err
  591. }
  592. var args []interface{}
  593. if entry.binding == nil {
  594. args = entry.Args
  595. } else {
  596. binding := &QueryInfo{
  597. Id: info.preparedID,
  598. Args: info.reqMeta.columns,
  599. Rval: info.respMeta.columns,
  600. }
  601. args, err = entry.binding(binding)
  602. if err != nil {
  603. return err
  604. }
  605. }
  606. if len(args) != len(info.reqMeta.columns) {
  607. return ErrQueryArgLength
  608. }
  609. b.preparedID = info.preparedID
  610. stmts[string(info.preparedID)] = entry.Stmt
  611. b.values = make([]queryValues, len(info.reqMeta.columns))
  612. for j := 0; j < len(info.reqMeta.columns); j++ {
  613. val, err := Marshal(info.reqMeta.columns[j].TypeInfo, args[j])
  614. if err != nil {
  615. return err
  616. }
  617. b.values[j].value = val
  618. // TODO: add names
  619. }
  620. } else {
  621. b.statement = entry.Stmt
  622. }
  623. }
  624. // TODO: should batch support tracing?
  625. resp, err := c.exec(req, nil)
  626. if err != nil {
  627. return err
  628. }
  629. switch x := resp.(type) {
  630. case *resultVoidFrame:
  631. return nil
  632. case *RequestErrUnprepared:
  633. stmt, found := stmts[string(x.StatementId)]
  634. if found {
  635. stmtsLRU.Lock()
  636. stmtsLRU.lru.Remove(c.addr + c.currentKeyspace + stmt)
  637. stmtsLRU.Unlock()
  638. }
  639. if found {
  640. return c.executeBatch(batch)
  641. } else {
  642. return x
  643. }
  644. case error:
  645. return x
  646. default:
  647. return NewErrProtocol("Unknown type in response to batch statement: %s", x)
  648. }
  649. }
  650. func (c *Conn) setKeepalive(d time.Duration) error {
  651. if tc, ok := c.conn.(*net.TCPConn); ok {
  652. err := tc.SetKeepAlivePeriod(d)
  653. if err != nil {
  654. return err
  655. }
  656. return tc.SetKeepAlive(true)
  657. }
  658. return nil
  659. }
  660. type inflightPrepare struct {
  661. info *resultPreparedFrame
  662. err error
  663. wg sync.WaitGroup
  664. }
  665. var (
  666. ErrQueryArgLength = errors.New("gocql: query argument length mismatch")
  667. ErrTimeoutNoResponse = errors.New("gocql: no response received from cassandra within timeout period")
  668. ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection")
  669. ErrConnectionClosed = errors.New("gocql: connection closed waiting for response")
  670. )