-
Notifications
You must be signed in to change notification settings - Fork 265
/
result.go
56 lines (47 loc) · 1.04 KB
/
result.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
package queryresult
import (
"time"
)
type TimingMetadata struct {
RowsFetched int64
CachedRowsFetched int64
HydrateCalls int64
}
type TimingResult struct {
Duration time.Duration
Metadata *TimingMetadata
}
type RowResult struct {
Data []interface{}
Error error
}
type Result struct {
RowChan *chan *RowResult
Cols []*ColumnDef
TimingResult chan *TimingResult
}
func NewResult(cols []*ColumnDef) *Result {
rowChan := make(chan *RowResult)
return &Result{
RowChan: &rowChan,
Cols: cols,
TimingResult: make(chan *TimingResult, 1),
}
}
// IsExportSourceData implements ExportSourceData
func (*Result) IsExportSourceData() {}
// Close closes the row channel
func (r *Result) Close() {
close(*r.RowChan)
}
func (r *Result) StreamRow(rowResult []interface{}) {
*r.RowChan <- &RowResult{Data: rowResult}
}
func (r *Result) StreamError(err error) {
*r.RowChan <- &RowResult{Error: err}
}
type SyncQueryResult struct {
Rows []interface{}
Cols []*ColumnDef
TimingResult *TimingResult
}