This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
globals.go
102 lines (88 loc) · 2.66 KB
/
globals.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cql
import (
"context"
"database/sql"
"fmt"
"log"
"os"
"github.com/gocql/gocql"
)
type (
// CqlDriverStruct is the sql driver
CqlDriverStruct struct {
// Logger is used to log connection ping errors
Logger *log.Logger
}
// CqlConnector is the sql driver connector
CqlConnector struct {
// Logger is used to log connection ping errors
Logger *log.Logger
// ClusterConfig is used for changing config options
// https://godoc.org/github.com/gocql/gocql#ClusterConfig
ClusterConfig *gocql.ClusterConfig
}
cqlConnStruct struct {
logger *log.Logger
clusterConfig *gocql.ClusterConfig
context context.Context
session *gocql.Session
pingQuery *gocql.Query
}
// CqlStmt is the sql driver statement
CqlStmt struct {
// CqlQuery is used for changing query options
// https://godoc.org/github.com/gocql/gocql#Query
// This will only work if Go sql every gives access to the driver
CqlQuery *gocql.Query
}
cqlResultStruct struct {
}
cqlRowsStruct struct {
iter *gocql.Iter
columns []string
}
converter struct{}
)
var (
// ErrNotSupported is returned for any method that is not supported
ErrNotSupported = fmt.Errorf("not supported")
// ErrNotImplementedYet is returned for any method that is not implemented yet
ErrNotImplementedYet = fmt.Errorf("not implemented yet")
// ErrQueryIsNil is returned when a query is nil
ErrQueryIsNil = fmt.Errorf("query is nil")
// ErrNamedValuesNotSupported is returned when values are named. Named values are not supported.
ErrNamedValuesNotSupported = fmt.Errorf("named values not supported")
// ErrOrdinalOutOfRange is returned when values ordinal is out of range
ErrOrdinalOutOfRange = fmt.Errorf("ordinal out of range")
// CqlDriver is the sql driver
CqlDriver = &CqlDriverStruct{
Logger: log.New(os.Stderr, "cql ", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile),
}
)
// DbConsistencyLevels maps string to gocql consistency levels
var DbConsistencyLevels = map[string]gocql.Consistency{
"any": gocql.Any,
"one": gocql.One,
"two": gocql.Two,
"three": gocql.Three,
"quorum": gocql.Quorum,
"all": gocql.All,
"localQuorum": gocql.LocalQuorum,
"eachQuorum": gocql.EachQuorum,
"localOne": gocql.LocalOne,
}
// DbConsistency maps gocql consistency levels to string
var DbConsistency = map[gocql.Consistency]string{
gocql.Any: "any",
gocql.One: "one",
gocql.Two: "two",
gocql.Three: "three",
gocql.Quorum: "quorum",
gocql.All: "all",
gocql.LocalQuorum: "localQuorum",
gocql.EachQuorum: "eachQuorum",
gocql.LocalOne: "localOne",
}
func init() {
sql.Register("cql", CqlDriver)
}