forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_query_service.go
87 lines (71 loc) · 3.53 KB
/
error_query_service.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
package fakes
import (
"fmt"
"github.com/youtube/vitess/go/sqltypes"
"github.com/youtube/vitess/go/vt/tabletserver/queryservice"
"github.com/youtube/vitess/go/vt/tabletserver/querytypes"
"golang.org/x/net/context"
querypb "github.com/youtube/vitess/go/vt/proto/query"
)
// ErrorQueryService is an implementation of QueryService that returns a
// configurable error for some of its methods.
//
// It is used as base for other, more specialised QueryService fakes e.g.
// StreamHealthQueryService.
type ErrorQueryService struct {
}
// Begin is part of QueryService interface
func (e *ErrorQueryService) Begin(ctx context.Context, target *querypb.Target) (int64, error) {
return 0, fmt.Errorf("ErrorQueryService does not implement any method")
}
// Commit is part of QueryService interface
func (e *ErrorQueryService) Commit(ctx context.Context, target *querypb.Target, transactionID int64) error {
return fmt.Errorf("ErrorQueryService does not implement any method")
}
// Rollback is part of QueryService interface
func (e *ErrorQueryService) Rollback(ctx context.Context, target *querypb.Target, transactionID int64) error {
return fmt.Errorf("ErrorQueryService does not implement any method")
}
// Execute is part of QueryService interface
func (e *ErrorQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, transactionID int64) (*sqltypes.Result, error) {
return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}
// StreamExecute is part of QueryService interface
func (e *ErrorQueryService) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sendReply func(*sqltypes.Result) error) error {
return fmt.Errorf("ErrorQueryService does not implement any method")
}
// ExecuteBatch is part of QueryService interface
func (e *ErrorQueryService) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []querytypes.BoundQuery, asTransaction bool, transactionID int64) ([]sqltypes.Result, error) {
return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}
// SplitQuery is part of QueryService interface
// TODO(erez): Remove once the migration to SplitQuery V2 is done.
func (e *ErrorQueryService) SplitQuery(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, splitColumn string, splitCount int64) ([]querytypes.QuerySplit, error) {
return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}
// SplitQueryV2 is part of QueryService interface
func (e *ErrorQueryService) SplitQueryV2(
ctx context.Context,
target *querypb.Target,
sql string,
bindVariables map[string]interface{},
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm,
) ([]querytypes.QuerySplit, error) {
return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}
// StreamHealthRegister is part of QueryService interface
func (e *ErrorQueryService) StreamHealthRegister(chan<- *querypb.StreamHealthResponse) (int, error) {
return 0, fmt.Errorf("ErrorQueryService does not implement any method")
}
// StreamHealthUnregister is part of QueryService interface
func (e *ErrorQueryService) StreamHealthUnregister(int) error {
return fmt.Errorf("ErrorQueryService does not implement any method")
}
// HandlePanic is part of QueryService interface
func (e *ErrorQueryService) HandlePanic(*error) {
}
// make sure ErrorQueryService implements QueryService
var _ queryservice.QueryService = &ErrorQueryService{}