gocql.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Any Consistency = iota
  43. One
  44. Two
  45. Three
  46. Quorum
  47. All
  48. LocalQuorum
  49. EachQuorum
  50. Serial
  51. LocalSerial
  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. ErrProtocol = errors.New("protocol error")
  64. )