зеркало из https://github.com/github/vitess-gh.git
Removing gorpc callerid and mysql/proto.
This commit is contained in:
Родитель
ad36a86ef0
Коммит
0e33839950
|
@ -1,50 +0,0 @@
|
|||
// Copyright 2012, Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/youtube/vitess/go/bson"
|
||||
"github.com/youtube/vitess/go/bytes2"
|
||||
)
|
||||
|
||||
// DO NOT EDIT.
|
||||
// FILE GENERATED BY BSONGEN.
|
||||
|
||||
// MarshalBson bson-encodes RPCError.
|
||||
func (rPCError *RPCError) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
|
||||
bson.EncodeOptionalPrefix(buf, bson.Object, key)
|
||||
lenWriter := bson.NewLenWriter(buf)
|
||||
|
||||
bson.EncodeInt64(buf, "Code", rPCError.Code)
|
||||
bson.EncodeString(buf, "Message", rPCError.Message)
|
||||
|
||||
lenWriter.Close()
|
||||
}
|
||||
|
||||
// UnmarshalBson bson-decodes into RPCError.
|
||||
func (rPCError *RPCError) UnmarshalBson(buf *bytes.Buffer, kind byte) {
|
||||
switch kind {
|
||||
case bson.EOO, bson.Object:
|
||||
// valid
|
||||
case bson.Null:
|
||||
return
|
||||
default:
|
||||
panic(bson.NewBsonError("unexpected kind %v for RPCError", kind))
|
||||
}
|
||||
bson.Next(buf, 4)
|
||||
|
||||
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
|
||||
switch bson.ReadCString(buf) {
|
||||
case "Code":
|
||||
rPCError.Code = bson.DecodeInt64(buf, kind)
|
||||
case "Message":
|
||||
rPCError.Message = bson.DecodeString(buf, kind)
|
||||
default:
|
||||
bson.Skip(buf, kind)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2012, Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package proto
|
||||
|
||||
// RPCError is the structure that is returned by each RPC call, which contains
|
||||
// the error information for that call.
|
||||
type RPCError struct {
|
||||
Code int64
|
||||
Message string
|
||||
}
|
||||
|
||||
//go:generate bsongen -file $GOFILE -type RPCError -o rpcerror_bson.go
|
|
@ -1,38 +0,0 @@
|
|||
package gorpccallerid
|
||||
|
||||
import (
|
||||
"github.com/youtube/vitess/go/vt/callerid"
|
||||
|
||||
querypb "github.com/youtube/vitess/go/vt/proto/query"
|
||||
vtrpcpb "github.com/youtube/vitess/go/vt/proto/vtrpc"
|
||||
)
|
||||
|
||||
// CallerID is the BSON implementation of the proto3 vtrpc.CallerID
|
||||
type CallerID struct {
|
||||
Principal string
|
||||
Component string
|
||||
Subcomponent string
|
||||
}
|
||||
|
||||
// VTGateCallerID is the BSON implementation of the proto3 query.VTGateCallerID
|
||||
type VTGateCallerID struct {
|
||||
Username string
|
||||
}
|
||||
|
||||
// GoRPCImmediateCallerID creates new ImmediateCallerID(querypb.VTGateCallerID)
|
||||
// from GoRPC's VTGateCallerID
|
||||
func GoRPCImmediateCallerID(v *VTGateCallerID) *querypb.VTGateCallerID {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return callerid.NewImmediateCallerID(v.Username)
|
||||
}
|
||||
|
||||
// GoRPCEffectiveCallerID creates new EffectiveCallerID(vtrpcpb.CallerID)
|
||||
// from GoRPC's CallerID
|
||||
func GoRPCEffectiveCallerID(c *CallerID) *vtrpcpb.CallerID {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return callerid.NewEffectiveCallerID(c.Principal, c.Component, c.Subcomponent)
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package gorpccallerid
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/youtube/vitess/go/vt/callerid/testsuite"
|
||||
)
|
||||
|
||||
func TestGoRPCCallerID(t *testing.T) {
|
||||
im := VTGateCallerID{
|
||||
Username: testsuite.FakeUsername,
|
||||
}
|
||||
ef := CallerID{
|
||||
Principal: testsuite.FakePrincipal,
|
||||
Component: testsuite.FakeComponent,
|
||||
Subcomponent: testsuite.FakeSubcomponent,
|
||||
}
|
||||
// Test nil cases
|
||||
if n := GoRPCImmediateCallerID(nil); n != nil {
|
||||
t.Errorf("Expect nil from GoRPCImmediateCallerID(nil), but got %v", n)
|
||||
}
|
||||
if n := GoRPCEffectiveCallerID(nil); n != nil {
|
||||
t.Errorf("Expect nil from GoRPCEffectiveCallerID(nil), but got %v", n)
|
||||
}
|
||||
testsuite.RunTests(t, GoRPCImmediateCallerID(&im), GoRPCEffectiveCallerID(&ef))
|
||||
}
|
|
@ -289,7 +289,7 @@ func (conn *gRPCQueryClient) StreamHealth(ctx context.Context) (tabletconn.Strea
|
|||
return conn.c.StreamHealth(ctx, &querypb.StreamHealthRequest{})
|
||||
}
|
||||
|
||||
// Close closes underlying bsonrpc.
|
||||
// Close closes underlying gRPC channel.
|
||||
func (conn *gRPCQueryClient) Close() {
|
||||
conn.mu.Lock()
|
||||
defer conn.mu.Unlock()
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
|
||||
log "github.com/golang/glog"
|
||||
"github.com/youtube/vitess/go/mysql"
|
||||
mproto "github.com/youtube/vitess/go/mysql/proto"
|
||||
"github.com/youtube/vitess/go/tb"
|
||||
"github.com/youtube/vitess/go/vt/logutil"
|
||||
vtrpcpb "github.com/youtube/vitess/go/vt/proto/vtrpc"
|
||||
|
@ -277,34 +276,3 @@ func logError(queryServiceStats *QueryServiceStats) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rpcErrFromTabletError translate a TabletError to an *mproto.RPCError
|
||||
func rpcErrFromTabletError(err error) *mproto.RPCError {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
terr, ok := err.(*TabletError)
|
||||
if ok {
|
||||
return &mproto.RPCError{
|
||||
Code: int64(terr.ErrorCode),
|
||||
// Make sure the the VitessError message is identical to the TabletError
|
||||
// err, so that downstream consumers will see identical messages no matter
|
||||
// which server version they're using.
|
||||
Message: terr.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
// We don't know exactly what the passed in error was
|
||||
return &mproto.RPCError{
|
||||
Code: int64(vtrpcpb.ErrorCode_UNKNOWN_ERROR),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
// AddTabletError will update a mproto.RPCError with details from a TabletError.
|
||||
func AddTabletError(err error, replyErr **mproto.RPCError) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
*replyErr = rpcErrFromTabletError(err)
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright 2012, Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package vterrors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
mproto "github.com/youtube/vitess/go/mysql/proto"
|
||||
|
||||
vtrpcpb "github.com/youtube/vitess/go/vt/proto/vtrpc"
|
||||
)
|
||||
|
||||
// This file contains methods to pack errors in and out of mproto.RPCError
|
||||
// and are only used by bson gorpc.
|
||||
|
||||
// FromRPCError recovers a VitessError from a *mproto.RPCError (which is how VitessErrors
|
||||
// are transmitted across RPC boundaries).
|
||||
func FromRPCError(rpcErr *mproto.RPCError) error {
|
||||
if rpcErr == nil {
|
||||
return nil
|
||||
}
|
||||
return &VitessError{
|
||||
Code: vtrpcpb.ErrorCode(rpcErr.Code),
|
||||
err: fmt.Errorf("%v", rpcErr.Message),
|
||||
}
|
||||
}
|
||||
|
||||
// RPCErrFromVtError convert from a VtError to an *mproto.RPCError
|
||||
func RPCErrFromVtError(err error) *mproto.RPCError {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &mproto.RPCError{
|
||||
Code: int64(RecoverVtErrorCode(err)),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче