gocql.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. "errors"
  7. )
  8. type queryContext interface {
  9. executeQuery(query *Query) (frame, error)
  10. }
  11. type ColumnInfo struct {
  12. Keyspace string
  13. Table string
  14. Name string
  15. TypeInfo *TypeInfo
  16. }
  17. type BatchType int
  18. const (
  19. LoggedBatch BatchType = 0
  20. UnloggedBatch BatchType = 1
  21. CounterBatch BatchType = 2
  22. )
  23. /*
  24. type Batch struct {
  25. queries []*Query
  26. ctx queryContext
  27. cons Consistency
  28. }
  29. func (b *Batch) Query(stmt string, args ...interface{}) *Query {
  30. return &Query{
  31. stmt: stmt,
  32. args: args,
  33. cons: b.cons,
  34. //ctx: b,
  35. }
  36. }
  37. func (b *Batch) Apply() error {
  38. return nil
  39. } */
  40. type Consistency uint16
  41. const (
  42. ConAny Consistency = 0x0000
  43. ConOne Consistency = 0x0001
  44. ConTwo Consistency = 0x0002
  45. ConThree Consistency = 0x0003
  46. ConQuorum Consistency = 0x0004
  47. ConAll Consistency = 0x0005
  48. ConLocalQuorum Consistency = 0x0006
  49. ConEachQuorum Consistency = 0x0007
  50. ConSerial Consistency = 0x0008
  51. ConLocalSerial Consistency = 0x0009
  52. )
  53. type Error struct {
  54. Code int
  55. Message string
  56. }
  57. func (e Error) Error() string {
  58. return e.Message
  59. }
  60. var (
  61. ErrNotFound = errors.New("not found")
  62. ErrNoHostAvailable = errors.New("no host available")
  63. ErrQueryUnbound = errors.New("can not execute unbound query")
  64. ErrProtocol = errors.New("protocol error")
  65. )