conn.go 17 KB

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