-
Notifications
You must be signed in to change notification settings - Fork 1
/
session.go
41 lines (35 loc) · 1.33 KB
/
session.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
package cassandra
import (
"context"
)
// Initializer is a common interface for functionality to start a new session
type Initializer interface {
NewSession(ctx context.Context) (Holder, error)
}
// Holder allows to store a close sessions
type Holder interface {
GetSession(ctx context.Context) SessionInterface
CloseSession(ctx context.Context)
}
// SessionInterface is an interface to wrap gocql methods used in Motiv
type SessionInterface interface {
Query(ctx context.Context, stmt string, values ...interface{}) QueryInterface
Close(ctx context.Context)
}
type QueryInterface interface {
Exec(ctx context.Context) error
Scan(ctx context.Context, dest ...interface{}) error
Iter(ctx context.Context) IterInterface
PageState(state []byte, ctx context.Context) QueryInterface
PageSize(n int, ctx context.Context) QueryInterface
}
type IterInterface interface {
Scan(ctx context.Context, dest ...interface{}) bool
WillSwitchPage(ctx context.Context) bool
PageState(ctx context.Context) []byte
MapScan(m map[string]interface{}, ctx context.Context) bool
//MapScanAndClose(m *map[string]interface{}, handle func() bool, ctx context.Context) error
Close(ctx context.Context) error
ScanAndClose(ctx context.Context, handle func() bool, dest ...interface{}) error
SliceMapAndClose(ctx context.Context) ([]map[string]interface{}, error)
}