当前位置: 首页>>代码示例>>Golang>>正文


Golang callerid.GoRPCEffectiveCallerID函数代码示例

本文整理汇总了Golang中github.com/youtube/vitess/go/vt/callerid.GoRPCEffectiveCallerID函数的典型用法代码示例。如果您正苦于以下问题:Golang GoRPCEffectiveCallerID函数的具体用法?Golang GoRPCEffectiveCallerID怎么用?Golang GoRPCEffectiveCallerID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GoRPCEffectiveCallerID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: StreamExecute2

// StreamExecute2 should not be used by anything other than tests.
// It will eventually replace Rollback, but it breaks compatibility with older clients.
// Once all clients are upgraded, it can be replaced.
func (sq *SqlQuery) StreamExecute2(ctx context.Context, req *proto.StreamExecuteRequest, sendReply func(reply interface{}) error) (err error) {
	defer sq.server.HandlePanic(&err)
	if req == nil || req.Query == nil {
		return nil
	}
	ctx = callerid.NewContext(ctx,
		callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID),
		callerid.GoRPCImmediateCallerID(req.ImmediateCallerID),
	)
	tErr := sq.server.StreamExecute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req.Query, func(reply *mproto.QueryResult) error {
		return sendReply(reply)
	})
	if tErr == nil {
		return nil
	}
	if *tabletserver.RPCErrorOnlyInReply {
		// If there was an app error, send a QueryResult back with it.
		qr := new(mproto.QueryResult)
		tabletserver.AddTabletErrorToQueryResult(tErr, 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 tErr
}
开发者ID:haoqoo,项目名称:vitess,代码行数:31,代码来源:sqlquery.go

示例3: 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

示例4: 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

示例5: Execute2

// Execute2 should not be used by anything other than tests
// It will eventually replace Execute, but it breaks compatibility with older clients
// Once all clients are upgraded, it can be replaced
func (sq *SqlQuery) Execute2(ctx context.Context, executeRequest *proto.ExecuteRequest, reply *mproto.QueryResult) (err error) {
	defer sq.server.HandlePanic(&err)
	ctx = callerid.NewContext(ctx,
		callerid.GoRPCEffectiveCallerID(executeRequest.EffectiveCallerID),
		callerid.GoRPCImmediateCallerID(executeRequest.ImmediateCallerID),
	)
	tErr := sq.server.Execute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(executeRequest.Target), &executeRequest.QueryRequest, reply)
	tabletserver.AddTabletError(tErr, &reply.Err)
	return nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:13,代码来源:sqlquery.go

示例6: SplitQuery

// SplitQuery is exposing tabletserver.SqlQuery.SplitQuery
func (sq *SqlQuery) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, reply *proto.SplitQueryResult) (err error) {
	defer sq.server.HandlePanic(&err)
	ctx = callerid.NewContext(ctx,
		callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID),
		callerid.GoRPCImmediateCallerID(req.ImmediateCallerID),
	)
	tErr := sq.server.SplitQuery(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req, reply)
	tabletserver.AddTabletError(tErr, &reply.Err)
	return nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:11,代码来源:sqlquery.go

示例7: 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

示例8: 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

示例9: ExecuteBatch2

// ExecuteBatch2 should not be used by anything other than tests
// It will eventually replace ExecuteBatch, but it breaks compatibility with older clients.
// Once all clients are upgraded, it can be replaced.
func (sq *SqlQuery) ExecuteBatch2(ctx context.Context, req *proto.ExecuteBatchRequest, reply *proto.QueryResultList) (err error) {
	defer sq.server.HandlePanic(&err)
	if req == nil {
		return nil
	}
	ctx = callerid.NewContext(ctx,
		callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID),
		callerid.GoRPCImmediateCallerID(req.ImmediateCallerID),
	)
	tErr := sq.server.ExecuteBatch(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), &req.QueryBatch, reply)
	tabletserver.AddTabletError(tErr, &reply.Err)
	return nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:16,代码来源:sqlquery.go

示例10: 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

示例11: 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

示例12: Commit2

// Commit2 is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) Commit2(ctx context.Context, request *proto.CommitRequest, reply *proto.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"))
	vtgErr := vtg.server.Commit(ctx, request.Session)
	vtgate.AddVtGateErrorToCommitResponse(vtgErr, reply)
	if *vtgate.RPCErrorOnlyInReply {
		return nil
	}
	return vtgErr
}
开发者ID:richarwu,项目名称:vitess,代码行数:15,代码来源:server.go

示例13: Commit2

// Commit2 should not be used by anything other than tests.
// It will eventually replace Commit, but it breaks compatibility with older clients.
// Once all clients are upgraded, it can be replaced.
func (sq *SqlQuery) Commit2(ctx context.Context, commitRequest *proto.CommitRequest, commitResponse *proto.CommitResponse) (err error) {
	defer sq.server.HandlePanic(&err)
	session := &proto.Session{
		SessionId:     commitRequest.SessionId,
		TransactionId: commitRequest.TransactionId,
	}
	ctx = callerid.NewContext(ctx,
		callerid.GoRPCEffectiveCallerID(commitRequest.EffectiveCallerID),
		callerid.GoRPCImmediateCallerID(commitRequest.ImmediateCallerID),
	)
	tErr := sq.server.Commit(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(commitRequest.Target), session)
	tabletserver.AddTabletError(tErr, &commitResponse.Err)
	return nil
}
开发者ID:hadmagic,项目名称:vitess,代码行数:17,代码来源:sqlquery.go

示例14: ExecuteEntityIds

// ExecuteEntityIds is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, request *proto.EntityIdsQuery, reply *proto.QueryResult) (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.ExecuteEntityIds(ctx, request, reply)
	vtgate.AddVtGateErrorToQueryResult(vtgErr, reply)
	if *vtgate.RPCErrorOnlyInReply {
		return nil
	}
	return vtgErr
}
开发者ID:haoqoo,项目名称:vitess,代码行数:15,代码来源:server.go

示例15: StreamExecute

// StreamExecute is the RPC version of vtgateservice.VTGateService method
func (vtg *VTGate) StreamExecute(ctx context.Context, request *gorpcvtgatecommon.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,
		request.TabletType,
		func(value *sqltypes.Result) error {
			return sendReply(&gorpcvtgatecommon.QueryResult{
				Result: value,
			})
		})
}
开发者ID:BobbWu,项目名称:vitess,代码行数:16,代码来源:server.go


注:本文中的github.com/youtube/vitess/go/vt/callerid.GoRPCEffectiveCallerID函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。