对服务增加基础的数据统计/部分代码分Package

This commit is contained in:
刘祥超
2021-01-25 16:40:03 +08:00
parent 1d4f01a062
commit e76441ba8e
106 changed files with 2095 additions and 148 deletions

View File

@@ -56,6 +56,12 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
return
}
// 是否是模拟测试
mockCtx, isMock := ctx.(*MockNodeContext)
if isMock {
return UserTypeNode, mockCtx.NodeId, nil
}
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return UserTypeNone, 0, errors.New("context: need 'nodeId'")