conn.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  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. if err != nil {
  375. return nil, err
  376. }
  377. case <-time.After(c.timeout):
  378. close(call.timeout)
  379. c.handleTimeout()
  380. return nil, ErrTimeoutNoResponse
  381. case <-c.quit:
  382. return nil, ErrConnectionClosed
  383. }
  384. // dont release the stream if detect a timeout as another request can reuse
  385. // that stream and get a response for the old request, which we have no
  386. // easy way of detecting.
  387. //
  388. // Ensure that the stream is not released if there are potentially outstanding
  389. // requests on the stream to prevent nil pointer dereferences in recv().
  390. defer c.releaseStream(stream)
  391. if v := framer.header.version.version(); v != c.version {
  392. return nil, NewErrProtocol("unexpected protocol version in response: got %d expected %d", v, c.version)
  393. }
  394. frame, err := framer.parseFrame()
  395. if err != nil {
  396. return nil, err
  397. }
  398. if len(framer.traceID) > 0 {
  399. tracer.Trace(framer.traceID)
  400. }
  401. return frame, nil
  402. }
  403. func (c *Conn) prepareStatement(stmt string, trace Tracer) (*resultPreparedFrame, error) {
  404. stmtsLRU.Lock()
  405. if stmtsLRU.lru == nil {
  406. initStmtsLRU(defaultMaxPreparedStmts)
  407. }
  408. stmtCacheKey := c.addr + c.currentKeyspace + stmt
  409. if val, ok := stmtsLRU.lru.Get(stmtCacheKey); ok {
  410. stmtsLRU.Unlock()
  411. flight := val.(*inflightPrepare)
  412. flight.wg.Wait()
  413. return flight.info, flight.err
  414. }
  415. flight := new(inflightPrepare)
  416. flight.wg.Add(1)
  417. stmtsLRU.lru.Add(stmtCacheKey, flight)
  418. stmtsLRU.Unlock()
  419. prep := &writePrepareFrame{
  420. statement: stmt,
  421. }
  422. resp, err := c.exec(prep, trace)
  423. if err != nil {
  424. flight.err = err
  425. flight.wg.Done()
  426. return nil, err
  427. }
  428. switch x := resp.(type) {
  429. case *resultPreparedFrame:
  430. flight.info = x
  431. case error:
  432. flight.err = x
  433. default:
  434. flight.err = NewErrProtocol("Unknown type in response to prepare frame: %s", x)
  435. }
  436. flight.wg.Done()
  437. if flight.err != nil {
  438. stmtsLRU.Lock()
  439. stmtsLRU.lru.Remove(stmtCacheKey)
  440. stmtsLRU.Unlock()
  441. }
  442. return flight.info, flight.err
  443. }
  444. func (c *Conn) executeQuery(qry *Query) *Iter {
  445. params := queryParams{
  446. consistency: qry.cons,
  447. }
  448. // frame checks that it is not 0
  449. params.serialConsistency = qry.serialCons
  450. params.defaultTimestamp = qry.defaultTimestamp
  451. if len(qry.pageState) > 0 {
  452. params.pagingState = qry.pageState
  453. }
  454. if qry.pageSize > 0 {
  455. params.pageSize = qry.pageSize
  456. }
  457. var frame frameWriter
  458. if qry.shouldPrepare() {
  459. // Prepare all DML queries. Other queries can not be prepared.
  460. info, err := c.prepareStatement(qry.stmt, qry.trace)
  461. if err != nil {
  462. return &Iter{err: err}
  463. }
  464. var values []interface{}
  465. if qry.binding == nil {
  466. values = qry.values
  467. } else {
  468. binding := &QueryInfo{
  469. Id: info.preparedID,
  470. Args: info.reqMeta.columns,
  471. Rval: info.respMeta.columns,
  472. }
  473. values, err = qry.binding(binding)
  474. if err != nil {
  475. return &Iter{err: err}
  476. }
  477. }
  478. if len(values) != len(info.reqMeta.columns) {
  479. return &Iter{err: ErrQueryArgLength}
  480. }
  481. params.values = make([]queryValues, len(values))
  482. for i := 0; i < len(values); i++ {
  483. val, err := Marshal(info.reqMeta.columns[i].TypeInfo, values[i])
  484. if err != nil {
  485. return &Iter{err: err}
  486. }
  487. v := &params.values[i]
  488. v.value = val
  489. // TODO: handle query binding names
  490. }
  491. frame = &writeExecuteFrame{
  492. preparedID: info.preparedID,
  493. params: params,
  494. }
  495. } else {
  496. frame = &writeQueryFrame{
  497. statement: qry.stmt,
  498. params: params,
  499. }
  500. }
  501. resp, err := c.exec(frame, qry.trace)
  502. if err != nil {
  503. return &Iter{err: err}
  504. }
  505. switch x := resp.(type) {
  506. case *resultVoidFrame:
  507. return &Iter{}
  508. case *resultRowsFrame:
  509. iter := &Iter{
  510. meta: x.meta,
  511. rows: x.rows,
  512. }
  513. if len(x.meta.pagingState) > 0 {
  514. iter.next = &nextIter{
  515. qry: *qry,
  516. pos: int((1 - qry.prefetch) * float64(len(iter.rows))),
  517. }
  518. iter.next.qry.pageState = x.meta.pagingState
  519. if iter.next.pos < 1 {
  520. iter.next.pos = 1
  521. }
  522. }
  523. return iter
  524. case *resultKeyspaceFrame, *resultSchemaChangeFrame:
  525. return &Iter{}
  526. case *RequestErrUnprepared:
  527. stmtsLRU.Lock()
  528. stmtCacheKey := c.addr + c.currentKeyspace + qry.stmt
  529. if _, ok := stmtsLRU.lru.Get(stmtCacheKey); ok {
  530. stmtsLRU.lru.Remove(stmtCacheKey)
  531. stmtsLRU.Unlock()
  532. return c.executeQuery(qry)
  533. }
  534. stmtsLRU.Unlock()
  535. return &Iter{err: x}
  536. case error:
  537. return &Iter{err: x}
  538. default:
  539. return &Iter{err: NewErrProtocol("Unknown type in response to execute query: %s", x)}
  540. }
  541. }
  542. func (c *Conn) Pick(qry *Query) *Conn {
  543. if c.Closed() {
  544. return nil
  545. }
  546. return c
  547. }
  548. func (c *Conn) Closed() bool {
  549. return atomic.LoadInt32(&c.closed) == 1
  550. }
  551. func (c *Conn) Address() string {
  552. return c.addr
  553. }
  554. func (c *Conn) AvailableStreams() int {
  555. return len(c.uniq)
  556. }
  557. func (c *Conn) UseKeyspace(keyspace string) error {
  558. q := &writeQueryFrame{statement: `USE "` + keyspace + `"`}
  559. q.params.consistency = Any
  560. resp, err := c.exec(q, nil)
  561. if err != nil {
  562. return err
  563. }
  564. switch x := resp.(type) {
  565. case *resultKeyspaceFrame:
  566. case error:
  567. return x
  568. default:
  569. return NewErrProtocol("unknown frame in response to USE: %v", x)
  570. }
  571. c.currentKeyspace = keyspace
  572. return nil
  573. }
  574. func (c *Conn) executeBatch(batch *Batch) error {
  575. if c.version == protoVersion1 {
  576. return ErrUnsupported
  577. }
  578. n := len(batch.Entries)
  579. req := &writeBatchFrame{
  580. typ: batch.Type,
  581. statements: make([]batchStatment, n),
  582. consistency: batch.Cons,
  583. serialConsistency: batch.serialCons,
  584. defaultTimestamp: batch.defaultTimestamp,
  585. }
  586. stmts := make(map[string]string)
  587. for i := 0; i < n; i++ {
  588. entry := &batch.Entries[i]
  589. b := &req.statements[i]
  590. if len(entry.Args) > 0 || entry.binding != nil {
  591. info, err := c.prepareStatement(entry.Stmt, nil)
  592. if err != nil {
  593. return err
  594. }
  595. var args []interface{}
  596. if entry.binding == nil {
  597. args = entry.Args
  598. } else {
  599. binding := &QueryInfo{
  600. Id: info.preparedID,
  601. Args: info.reqMeta.columns,
  602. Rval: info.respMeta.columns,
  603. }
  604. args, err = entry.binding(binding)
  605. if err != nil {
  606. return err
  607. }
  608. }
  609. if len(args) != len(info.reqMeta.columns) {
  610. return ErrQueryArgLength
  611. }
  612. b.preparedID = info.preparedID
  613. stmts[string(info.preparedID)] = entry.Stmt
  614. b.values = make([]queryValues, len(info.reqMeta.columns))
  615. for j := 0; j < len(info.reqMeta.columns); j++ {
  616. val, err := Marshal(info.reqMeta.columns[j].TypeInfo, args[j])
  617. if err != nil {
  618. return err
  619. }
  620. b.values[j].value = val
  621. // TODO: add names
  622. }
  623. } else {
  624. b.statement = entry.Stmt
  625. }
  626. }
  627. // TODO: should batch support tracing?
  628. resp, err := c.exec(req, nil)
  629. if err != nil {
  630. return err
  631. }
  632. switch x := resp.(type) {
  633. case *resultVoidFrame:
  634. return nil
  635. case *RequestErrUnprepared:
  636. stmt, found := stmts[string(x.StatementId)]
  637. if found {
  638. stmtsLRU.Lock()
  639. stmtsLRU.lru.Remove(c.addr + c.currentKeyspace + stmt)
  640. stmtsLRU.Unlock()
  641. }
  642. if found {
  643. return c.executeBatch(batch)
  644. } else {
  645. return x
  646. }
  647. case error:
  648. return x
  649. default:
  650. return NewErrProtocol("Unknown type in response to batch statement: %s", x)
  651. }
  652. }
  653. func (c *Conn) setKeepalive(d time.Duration) error {
  654. if tc, ok := c.conn.(*net.TCPConn); ok {
  655. err := tc.SetKeepAlivePeriod(d)
  656. if err != nil {
  657. return err
  658. }
  659. return tc.SetKeepAlive(true)
  660. }
  661. return nil
  662. }
  663. type inflightPrepare struct {
  664. info *resultPreparedFrame
  665. err error
  666. wg sync.WaitGroup
  667. }
  668. var (
  669. ErrQueryArgLength = errors.New("gocql: query argument length mismatch")
  670. ErrTimeoutNoResponse = errors.New("gocql: no response received from cassandra within timeout period")
  671. ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection")
  672. ErrConnectionClosed = errors.New("gocql: connection closed waiting for response")
  673. )