本文整理汇总了Golang中github.com/youtube/vitess/go/vt/callerid.NewImmediateCallerID函数的典型用法代码示例。如果您正苦于以下问题:Golang NewImmediateCallerID函数的具体用法?Golang NewImmediateCallerID怎么用?Golang NewImmediateCallerID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewImmediateCallerID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExecuteKeyspaceIds
// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *pb.ExecuteKeyspaceIdsRequest) (response *pb.ExecuteKeyspaceIdsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResult)
bv, err := tproto.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
executeErr := vtg.server.ExecuteKeyspaceIds(ctx,
string(request.Query.Sql),
bv,
request.Keyspace,
request.KeyspaceIds,
request.TabletType,
request.Session,
request.NotInTransaction,
reply)
response = &pb.ExecuteKeyspaceIdsResponse{
Error: vtgate.RPCErrorToVtRPCError(reply.Err),
}
if executeErr != nil {
return nil, vterrors.ToGRPCError(executeErr)
}
response.Result = sqltypes.ResultToProto3(reply.Result)
response.Session = reply.Session
return response, nil
}
开发者ID:tjyang,项目名称:vitess,代码行数:30,代码来源:server.go
示例2: SplitQuery
// SplitQuery is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) SplitQuery(ctx context.Context, request *vtgatepb.SplitQueryRequest) (response *vtgatepb.SplitQueryResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
bv, err := querytypes.Proto3ToBindVariables(request.Query.BindVariables)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
splits, vtgErr := vtgateservice.CallCorrectSplitQuery(
vtg.server,
request.UseSplitQueryV2,
ctx,
request.Keyspace,
string(request.Query.Sql),
bv,
request.SplitColumn,
request.SplitCount,
request.NumRowsPerQueryPart,
request.Algorithm)
if vtgErr != nil {
return nil, vterrors.ToGRPCError(vtgErr)
}
return &vtgatepb.SplitQueryResponse{
Splits: splits,
}, nil
}
开发者ID:aaijazi,项目名称:vitess,代码行数:29,代码来源:server.go
示例3: StreamExecuteKeyRanges2
// StreamExecuteKeyRanges2 is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGateP3) StreamExecuteKeyRanges2(ctx context.Context, request *pb.StreamExecuteKeyRangesRequest, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
request.CallerId,
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.StreamExecuteKeyRanges(ctx,
string(request.Query.Sql),
tproto.Proto3ToBindVariables(request.Query.BindVariables),
request.Keyspace,
request.KeyRanges,
request.TabletType,
func(reply *proto.QueryResult) error {
return sendReply(&pb.StreamExecuteKeyRangesResponse{
Error: vtgate.VtGateErrorToVtRPCError(nil, reply.Error),
Result: mproto.QueryResultToProto3(reply.Result),
})
})
if vtgErr == nil {
return nil
}
if *vtgate.RPCErrorOnlyInReply {
// If there was an app error, send a QueryResult back with it.
// Sending back errors this way is not backwards compatible. If a (new) server sends an additional
// QueryResult with an error, and the (old) client doesn't know how to read it, it will cause
// problems where the client will get out of sync with the number of QueryResults sent.
// That's why this the error is only sent this way when the --rpc_errors_only_in_reply flag is set
// (signalling that all clients are able to handle new-style errors).
return sendReply(&pb.StreamExecuteKeyRangesResponse{
Error: vtgate.VtGateErrorToVtRPCError(vtgErr, ""),
})
}
return vtgErr
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:35,代码来源:server.go
示例4: testHandler
func testHandler(req *http.Request, t *testing.T) {
response := httptest.NewRecorder()
TxLogger.Send("test msg")
txlogzHandler(response, req)
if !strings.Contains(response.Body.String(), "error") {
t.Fatalf("should show an error page since transaction log format is invalid.")
}
txConn := &TxConnection{
TransactionID: 123456,
StartTime: time.Now(),
Queries: []string{"select * from test"},
Conclusion: "unknown",
LogToFile: sync2.AtomicInt32{},
EffectiveCallerID: callerid.NewEffectiveCallerID("effective-caller", "component", "subcomponent"),
ImmediateCallerID: callerid.NewImmediateCallerID("immediate-caller"),
}
txConn.EndTime = txConn.StartTime
response = httptest.NewRecorder()
TxLogger.Send(txConn)
txlogzHandler(response, req)
txConn.EndTime = txConn.StartTime.Add(time.Duration(2) * time.Second)
response = httptest.NewRecorder()
TxLogger.Send(txConn)
txlogzHandler(response, req)
txConn.EndTime = txConn.StartTime.Add(time.Duration(500) * time.Millisecond)
response = httptest.NewRecorder()
TxLogger.Send(txConn)
txlogzHandler(response, req)
}
开发者ID:littleyang,项目名称:vitess,代码行数:30,代码来源:txlogz_test.go
示例5: StreamExecuteKeyRanges2
// StreamExecuteKeyRanges2 is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecuteKeyRanges2(ctx context.Context, request *gorpcvtgatecommon.KeyRangeQuery, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.StreamExecuteKeyRanges(ctx,
request.Sql,
request.BindVariables,
request.Keyspace,
request.KeyRanges,
request.TabletType,
func(value *sqltypes.Result) error {
return sendReply(&gorpcvtgatecommon.QueryResult{
Result: value,
})
})
if vtgErr == nil {
return nil
}
// If there was an app error, send a QueryResult back with it.
return sendReply(&gorpcvtgatecommon.QueryResult{
Err: vterrors.RPCErrFromVtError(vtgErr),
})
}
开发者ID:BobbWu,项目名称:vitess,代码行数:27,代码来源:server.go
示例6: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, request *pb.ExecuteBatchKeyspaceIdsRequest) (response *pb.ExecuteBatchKeyspaceIdsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResultList)
bq, err := proto.ProtoToBoundKeyspaceIdQueries(request.Queries)
if err != nil {
return nil, vterrors.ToGRPCError(err)
}
executeErr := vtg.server.ExecuteBatchKeyspaceIds(ctx,
bq,
request.TabletType,
request.AsTransaction,
request.Session,
reply)
response = &pb.ExecuteBatchKeyspaceIdsResponse{
Error: vtgate.RPCErrorToVtRPCError(reply.Err),
}
if executeErr != nil {
return nil, vterrors.ToGRPCError(executeErr)
}
response.Results = tproto.QueryResultListToProto3(reply.List)
response.Session = reply.Session
return response, nil
}
开发者ID:tjyang,项目名称:vitess,代码行数:28,代码来源:server.go
示例7: ExecuteKeyspaceIds
// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) ExecuteKeyspaceIds(ctx context.Context, request *pb.ExecuteKeyspaceIdsRequest, response *pb.ExecuteKeyspaceIdsResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
request.CallerId,
callerid.NewImmediateCallerID("gorpc client"))
reply := &proto.QueryResult{}
vtgErr := vtg.server.ExecuteKeyspaceIds(ctx,
string(request.Query.Sql),
tproto.Proto3ToBindVariables(request.Query.BindVariables),
request.Keyspace,
request.KeyspaceIds,
request.TabletType,
proto.ProtoToSession(request.Session),
request.NotInTransaction,
reply)
response.Error = vtgate.VtGateErrorToVtRPCError(vtgErr, reply.Error)
response.Result = mproto.QueryResultToProto3(reply.Result)
response.Session = proto.SessionToProto(reply.Session)
if *vtgate.RPCErrorOnlyInReply {
return nil
}
return vtgErr
}
开发者ID:ruiaylin,项目名称:vitess,代码行数:26,代码来源:server.go
示例8: ExecuteKeyspaceIds
// ExecuteKeyspaceIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, request *pb.ExecuteKeyspaceIdsRequest) (response *pb.ExecuteKeyspaceIdsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResult)
executeErr := vtg.server.ExecuteKeyspaceIds(ctx,
string(request.Query.Sql),
tproto.Proto3ToBindVariables(request.Query.BindVariables),
request.Keyspace,
key.ProtoToKeyspaceIds(request.KeyspaceIds),
request.TabletType,
proto.ProtoToSession(request.Session),
request.NotInTransaction,
reply)
response = &pb.ExecuteKeyspaceIdsResponse{
Error: vtgate.VtGateErrorToVtRPCError(executeErr, reply.Error),
}
if executeErr == nil {
response.Result = mproto.QueryResultToProto3(reply.Result)
response.Session = proto.SessionToProto(reply.Session)
return response, nil
}
if *vtgate.RPCErrorOnlyInReply {
return response, nil
}
return nil, executeErr
}
开发者ID:payintel,项目名称:vitess,代码行数:29,代码来源:server.go
示例9: ExecuteBatchShards
// ExecuteBatchShards is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, request *pb.ExecuteBatchShardsRequest) (response *pb.ExecuteBatchShardsResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
reply := new(proto.QueryResultList)
executeErr := vtg.server.ExecuteBatchShards(ctx,
proto.ProtoToBoundShardQueries(request.Queries),
request.TabletType,
request.AsTransaction,
proto.ProtoToSession(request.Session),
reply)
response = &pb.ExecuteBatchShardsResponse{
Error: vtgate.VtGateErrorToVtRPCError(executeErr, reply.Error),
}
if executeErr == nil {
response.Results = tproto.QueryResultListToProto3(reply.List)
response.Session = proto.SessionToProto(reply.Session)
return response, nil
}
if *vtgate.RPCErrorOnlyInReply {
return response, nil
}
return nil, executeErr
}
开发者ID:payintel,项目名称:vitess,代码行数:26,代码来源:server.go
示例10: ExecuteEntityIds
// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) ExecuteEntityIds(ctx context.Context, request *pb.ExecuteEntityIdsRequest, response *pb.ExecuteEntityIdsResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
request.CallerId,
callerid.NewImmediateCallerID("bsonp3 client"))
reply := new(proto.QueryResult)
executeErr := vtg.server.ExecuteEntityIds(ctx,
string(request.Query.Sql),
tproto.Proto3ToBindVariables(request.Query.BindVariables),
request.Keyspace,
request.EntityColumnName,
request.EntityKeyspaceIds,
request.TabletType,
proto.ProtoToSession(request.Session),
request.NotInTransaction,
reply)
if executeErr == nil {
response.Error = vtgate.RPCErrorToVtRPCError(reply.Err)
response.Result = mproto.QueryResultToProto3(reply.Result)
response.Session = proto.SessionToProto(reply.Session)
}
return vterrors.ToJSONError(executeErr)
}
开发者ID:richarwu,项目名称:vitess,代码行数:26,代码来源:server.go
示例11: StreamExecuteKeyRanges2
// StreamExecuteKeyRanges2 is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecuteKeyRanges2(ctx context.Context, request *proto.KeyRangeQuery, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.StreamExecuteKeyRanges(ctx,
request.Sql,
request.BindVariables,
request.Keyspace,
key.KeyRangesToProto(request.KeyRanges),
topo.TabletTypeToProto(request.TabletType),
func(value *proto.QueryResult) error {
return sendReply(value)
})
if vtgErr == nil {
return nil
}
if *vtgate.RPCErrorOnlyInReply {
// If there was an app error, send a QueryResult back with it.
qr := new(proto.QueryResult)
vtgate.AddVtGateErrorToQueryResult(vtgErr, qr)
// Sending back errors this way is not backwards compatible. If a (new) server sends an additional
// QueryResult with an error, and the (old) client doesn't know how to read it, it will cause
// problems where the client will get out of sync with the number of QueryResults sent.
// That's why this the error is only sent this way when the --rpc_errors_only_in_reply flag is set
// (signalling that all clients are able to handle new-style errors).
return sendReply(qr)
}
return vtgErr
}
开发者ID:richarwu,项目名称:vitess,代码行数:32,代码来源:server.go
示例12: StreamExecuteKeyspaceIds
// StreamExecuteKeyspaceIds is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, request *proto.KeyspaceIdQuery, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
return vtg.server.StreamExecuteKeyspaceIds(ctx, request, func(value *proto.QueryResult) error {
return sendReply(value)
})
}
开发者ID:haoqoo,项目名称:vitess,代码行数:11,代码来源:server.go
示例13: Rollback
// Rollback is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGateP3) Rollback(ctx context.Context, request *pb.RollbackRequest, response *pb.RollbackResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
request.CallerId,
callerid.NewImmediateCallerID("bsonp3 client"))
vtgErr := vtg.server.Rollback(ctx, proto.ProtoToSession(request.Session))
return vterrors.ToJSONError(vtgErr)
}
开发者ID:richarwu,项目名称:vitess,代码行数:11,代码来源:server.go
示例14: Rollback2
// Rollback2 is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Rollback2(ctx context.Context, request *proto.RollbackRequest, reply *proto.RollbackResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
vtgErr := vtg.server.Rollback(ctx, request.Session)
vtgate.AddVtGateError(vtgErr, &reply.Err)
return nil
}
开发者ID:khanchan,项目名称:vitess,代码行数:12,代码来源:server.go
示例15: Commit2
// Commit2 is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Commit2(ctx context.Context, request *gorpcvtgatecommon.CommitRequest, reply *gorpcvtgatecommon.CommitResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
sessionFromRPC(request.Session)
vtgErr := vtg.server.Commit(ctx, request.Session)
reply.Err = vterrors.RPCErrFromVtError(vtgErr)
return nil
}
开发者ID:BobbWu,项目名称:vitess,代码行数:13,代码来源:server.go
示例16: withCallerIDContext
// withCallerIDContext creates a context that extracts what we need
// from the incoming call and can be forwarded for use when talking to vttablet.
func withCallerIDContext(ctx context.Context, effectiveCallerID *vtrpcpb.CallerID) context.Context {
immediate := immediateCallerID(ctx)
if immediate == "" && *useEffective && effectiveCallerID != nil {
immediate = effectiveCallerID.Principal
}
if immediate == "" {
immediate = unsecureClient
}
return callerid.NewContext(callinfo.GRPCCallInfo(ctx),
effectiveCallerID,
callerid.NewImmediateCallerID(immediate))
}
开发者ID:CowLeo,项目名称:vitess,代码行数:14,代码来源:server.go
示例17: Commit
// Commit is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Commit(ctx context.Context, request *vtgatepb.CommitRequest) (response *vtgatepb.CommitResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
vtgErr := vtg.server.Commit(ctx, request.Session)
response = &vtgatepb.CommitResponse{}
if vtgErr == nil {
return response, nil
}
return nil, vterrors.ToGRPCError(vtgErr)
}
开发者ID:BobbWu,项目名称:vitess,代码行数:13,代码来源:server.go
示例18: Begin2
// Begin2 is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Begin2(ctx context.Context, request *gorpcvtgatecommon.BeginRequest, reply *gorpcvtgatecommon.BeginResponse) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
// Don't pass in a nil pointer
session, vtgErr := vtg.server.Begin(ctx)
reply.Session = sessionToRPC(session)
reply.Err = vterrors.RPCErrFromVtError(vtgErr)
return nil
}
开发者ID:BobbWu,项目名称:vitess,代码行数:14,代码来源:server.go
示例19: StreamExecute
// StreamExecute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecute(ctx context.Context, request *proto.Query, sendReply func(interface{}) error) (err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
return vtg.server.StreamExecute(ctx,
request.Sql,
request.BindVariables,
topo.TabletTypeToProto(request.TabletType),
func(value *proto.QueryResult) error {
return sendReply(value)
})
}
开发者ID:richarwu,项目名称:vitess,代码行数:14,代码来源:server.go
示例20: Begin
// Begin is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Begin(ctx context.Context, request *vtgatepb.BeginRequest) (response *vtgatepb.BeginResponse, err error) {
defer vtg.server.HandlePanic(&err)
ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
request.CallerId,
callerid.NewImmediateCallerID("grpc client"))
session, vtgErr := vtg.server.Begin(ctx)
if vtgErr == nil {
return &vtgatepb.BeginResponse{
Session: session,
}, nil
}
return nil, vterrors.ToGRPCError(vtgErr)
}
开发者ID:BobbWu,项目名称:vitess,代码行数:14,代码来源:server.go
注:本文中的github.com/youtube/vitess/go/vt/callerid.NewImmediateCallerID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论