-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.go
79 lines (58 loc) · 1.41 KB
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cql
import (
"context"
"github.com/upfluence/errors"
)
var ErrNoRows = errors.New("No rows found")
//go:generate stringer -type=BatchType
type BatchType uint8
const (
LoggedBatch BatchType = iota
UnloggedBatch
CounterBatch
)
type Option interface {
IsCQLOption()
}
//go:generate stringer -type=Consistency
type Consistency uint16
const (
Any Consistency = 0x00
One Consistency = 0x01
Two Consistency = 0x02
Three Consistency = 0x03
Quorum Consistency = 0x04
All Consistency = 0x05
LocalQuorum Consistency = 0x06
EachQuorum Consistency = 0x07
LocalOne Consistency = 0x0A
)
type WithConsistency Consistency
func (WithConsistency) IsCQLOption() {}
type NamedQuery string
func (nq NamedQuery) IsCQLOption() {}
type CASScanner interface {
ScanCAS(...interface{}) (bool, error)
}
type Scanner interface {
Scan(...interface{}) error
}
type Cursor interface {
Scan(...interface{}) bool
Close() error
}
type Batch interface {
Query(string, ...interface{})
Exec() error
ExecCAS() (bool, Cursor, error)
}
type DB interface {
Exec(context.Context, string, ...interface{}) error
ExecCAS(context.Context, string, ...interface{}) CASScanner
QueryRow(context.Context, string, ...interface{}) Scanner
Query(context.Context, string, ...interface{}) Cursor
Batch(context.Context, BatchType, ...Option) Batch
}
type MiddlewareFactory interface {
Wrap(DB) DB
}