巅峰赛,合成西瓜总数
All checks were successful
/ build-services (app/auth_service/Dockerfile, auth, auth) (push) Successful in 37s
/ build-services (app/ecpm_service/Dockerfile, ecpm, ecpm) (push) Successful in 35s
/ build-services (app/ranking_service/Dockerfile, ranking, ranking) (push) Successful in 37s
/ build-services (app/user_service/Dockerfile, user, user) (push) Successful in 38s
/ start-services (push) Successful in 5s
All checks were successful
/ build-services (app/auth_service/Dockerfile, auth, auth) (push) Successful in 37s
/ build-services (app/ecpm_service/Dockerfile, ecpm, ecpm) (push) Successful in 35s
/ build-services (app/ranking_service/Dockerfile, ranking, ranking) (push) Successful in 37s
/ build-services (app/user_service/Dockerfile, user, user) (push) Successful in 38s
/ start-services (push) Successful in 5s
This commit is contained in:
parent
b9018c33aa
commit
ac005aa95d
@ -0,0 +1,37 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/logic/rankings"
|
||||
"strconv"
|
||||
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/svc"
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/ranking"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddUserGameScoreLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddUserGameScoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddUserGameScoreLogic {
|
||||
return &AddUserGameScoreLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AddUserGameScoreLogic) AddUserGameScore(in *ranking.AddUserGameScoreRequest) (*ranking.BaseResult, error) {
|
||||
cacheKey := rankings.GetRankingsCacheKey(in.AppId, in.Type)
|
||||
|
||||
_, err := l.svcCtx.RedisRanking.IncrScore(l.ctx, cacheKey, strconv.Itoa(int(in.UserId)), float64(in.Score))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ranking.BaseResult{}, nil
|
||||
}
|
@ -43,3 +43,13 @@ func (r *Ranking) GetRank(ctx context.Context, key, member string) (rank int64,
|
||||
func (r *Ranking) GetScore(ctx context.Context, key, member string) (score float64, err error) {
|
||||
return r.c.ZScore(ctx, key, member).Result()
|
||||
}
|
||||
|
||||
// IncrScore 增加分数
|
||||
func (r *Ranking) IncrScore(ctx context.Context, key, member string, increment float64) (score float64, err error) {
|
||||
return r.c.ZIncrBy(ctx, key, increment, member).Result()
|
||||
}
|
||||
|
||||
// Remove 删除排行榜
|
||||
func (r *Ranking) Remove(ctx context.Context, key string) (err error) {
|
||||
return r.c.Del(ctx, key).Err()
|
||||
}
|
||||
|
34
app/ranking_service/internal/logic/remove_ranking_logic.go
Normal file
34
app/ranking_service/internal/logic/remove_ranking_logic.go
Normal file
@ -0,0 +1,34 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/logic/rankings"
|
||||
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/svc"
|
||||
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/ranking"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RemoveRankingLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewRemoveRankingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveRankingLogic {
|
||||
return &RemoveRankingLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *RemoveRankingLogic) RemoveRanking(in *ranking.RemoveRankingRequest) (*ranking.BaseResult, error) {
|
||||
cacheKey := rankings.GetRankingsCacheKey(in.AppId, in.Type)
|
||||
err := l.svcCtx.RedisRanking.Remove(l.ctx, cacheKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ranking.BaseResult{}, nil
|
||||
}
|
@ -37,3 +37,13 @@ func (s *RankingServiceServer) GetRankingList(ctx context.Context, in *ranking.G
|
||||
l := logic.NewGetRankingListLogic(ctx, s.svcCtx)
|
||||
return l.GetRankingList(in)
|
||||
}
|
||||
|
||||
func (s *RankingServiceServer) AddUserGameScore(ctx context.Context, in *ranking.AddUserGameScoreRequest) (*ranking.BaseResult, error) {
|
||||
l := logic.NewAddUserGameScoreLogic(ctx, s.svcCtx)
|
||||
return l.AddUserGameScore(in)
|
||||
}
|
||||
|
||||
func (s *RankingServiceServer) RemoveRanking(ctx context.Context, in *ranking.RemoveRankingRequest) (*ranking.BaseResult, error) {
|
||||
l := logic.NewRemoveRankingLogic(ctx, s.svcCtx)
|
||||
return l.RemoveRanking(in)
|
||||
}
|
||||
|
@ -420,6 +420,126 @@ func (x *BaseResult) GetErrorMsg() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type AddUserGameScoreRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type uint32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
|
||||
AppId uint32 `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"`
|
||||
UserId uint32 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"`
|
||||
Score uint32 `protobuf:"varint,4,opt,name=score,proto3" json:"score,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) Reset() {
|
||||
*x = AddUserGameScoreRequest{}
|
||||
mi := &file_ranking_service_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AddUserGameScoreRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AddUserGameScoreRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ranking_service_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AddUserGameScoreRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AddUserGameScoreRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ranking_service_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) GetType() uint32 {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) GetAppId() uint32 {
|
||||
if x != nil {
|
||||
return x.AppId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) GetUserId() uint32 {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *AddUserGameScoreRequest) GetScore() uint32 {
|
||||
if x != nil {
|
||||
return x.Score
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RemoveRankingRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
AppId uint32 `protobuf:"varint,1,opt,name=appId,proto3" json:"appId,omitempty"`
|
||||
Type uint32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RemoveRankingRequest) Reset() {
|
||||
*x = RemoveRankingRequest{}
|
||||
mi := &file_ranking_service_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RemoveRankingRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RemoveRankingRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RemoveRankingRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ranking_service_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RemoveRankingRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RemoveRankingRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ranking_service_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *RemoveRankingRequest) GetAppId() uint32 {
|
||||
if x != nil {
|
||||
return x.AppId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RemoveRankingRequest) GetType() uint32 {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_ranking_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_ranking_service_proto_rawDesc = string([]byte{
|
||||
@ -462,25 +582,47 @@ var file_ranking_service_proto_rawDesc = string([]byte{
|
||||
0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x65, 0x72,
|
||||
0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f,
|
||||
0x72, 0x4d, 0x73, 0x67, 0x32, 0x8c, 0x02, 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67,
|
||||
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67,
|
||||
0x12, 0x18, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||
0x63, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x6e,
|
||||
0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x10, 0x53, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72,
|
||||
0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x28, 0x2e, 0x72, 0x61, 0x6e, 0x6b,
|
||||
0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x74, 0x55,
|
||||
0x73, 0x65, 0x72, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74,
|
||||
0x12, 0x61, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x12, 0x26, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x72, 0x61, 0x6e,
|
||||
0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74,
|
||||
0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x72, 0x4d, 0x73, 0x67, 0x22, 0x71, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x47,
|
||||
0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65,
|
||||
0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49,
|
||||
0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d,
|
||||
0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x40, 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76,
|
||||
0x65, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05,
|
||||
0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x32, 0xbc, 0x03, 0x0a, 0x0f, 0x72, 0x61,
|
||||
0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a,
|
||||
0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x19, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x10, 0x53, 0x65,
|
||||
0x74, 0x55, 0x73, 0x65, 0x72, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x28,
|
||||
0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x2e, 0x53, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69,
|
||||
0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x61, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x6b,
|
||||
0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x26, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e,
|
||||
0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e,
|
||||
0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x27, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x55,
|
||||
0x73, 0x65, 0x72, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x28, 0x2e, 0x72,
|
||||
0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41,
|
||||
0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67,
|
||||
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73,
|
||||
0x75, 0x6c, 0x74, 0x12, 0x53, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x61, 0x6e,
|
||||
0x6b, 0x69, 0x6e, 0x67, 0x12, 0x25, 0x2e, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x61, 0x6e,
|
||||
0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x61,
|
||||
0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x61,
|
||||
0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x72, 0x61,
|
||||
0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
@ -495,7 +637,7 @@ func file_ranking_service_proto_rawDescGZIP() []byte {
|
||||
return file_ranking_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_ranking_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_ranking_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_ranking_service_proto_goTypes = []any{
|
||||
(*Request)(nil), // 0: ranking_service.Request
|
||||
(*Response)(nil), // 1: ranking_service.Response
|
||||
@ -504,17 +646,23 @@ var file_ranking_service_proto_goTypes = []any{
|
||||
(*GetRankingListResponse)(nil), // 4: ranking_service.GetRankingListResponse
|
||||
(*GetRankingListRequest)(nil), // 5: ranking_service.GetRankingListRequest
|
||||
(*BaseResult)(nil), // 6: ranking_service.BaseResult
|
||||
(*AddUserGameScoreRequest)(nil), // 7: ranking_service.AddUserGameScoreRequest
|
||||
(*RemoveRankingRequest)(nil), // 8: ranking_service.RemoveRankingRequest
|
||||
}
|
||||
var file_ranking_service_proto_depIdxs = []int32{
|
||||
3, // 0: ranking_service.GetRankingListResponse.rankingData:type_name -> ranking_service.RankingList
|
||||
0, // 1: ranking_service.ranking_service.Ping:input_type -> ranking_service.Request
|
||||
2, // 2: ranking_service.ranking_service.SetUserGameScore:input_type -> ranking_service.SetUserGameScoreRequest
|
||||
5, // 3: ranking_service.ranking_service.GetRankingList:input_type -> ranking_service.GetRankingListRequest
|
||||
1, // 4: ranking_service.ranking_service.Ping:output_type -> ranking_service.Response
|
||||
6, // 5: ranking_service.ranking_service.SetUserGameScore:output_type -> ranking_service.BaseResult
|
||||
4, // 6: ranking_service.ranking_service.GetRankingList:output_type -> ranking_service.GetRankingListResponse
|
||||
4, // [4:7] is the sub-list for method output_type
|
||||
1, // [1:4] is the sub-list for method input_type
|
||||
7, // 4: ranking_service.ranking_service.AddUserGameScore:input_type -> ranking_service.AddUserGameScoreRequest
|
||||
8, // 5: ranking_service.ranking_service.RemoveRanking:input_type -> ranking_service.RemoveRankingRequest
|
||||
1, // 6: ranking_service.ranking_service.Ping:output_type -> ranking_service.Response
|
||||
6, // 7: ranking_service.ranking_service.SetUserGameScore:output_type -> ranking_service.BaseResult
|
||||
4, // 8: ranking_service.ranking_service.GetRankingList:output_type -> ranking_service.GetRankingListResponse
|
||||
6, // 9: ranking_service.ranking_service.AddUserGameScore:output_type -> ranking_service.BaseResult
|
||||
6, // 10: ranking_service.ranking_service.RemoveRanking:output_type -> ranking_service.BaseResult
|
||||
6, // [6:11] is the sub-list for method output_type
|
||||
1, // [1:6] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
@ -531,7 +679,7 @@ func file_ranking_service_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_ranking_service_proto_rawDesc), len(file_ranking_service_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
@ -22,6 +22,8 @@ const (
|
||||
RankingService_Ping_FullMethodName = "/ranking_service.ranking_service/Ping"
|
||||
RankingService_SetUserGameScore_FullMethodName = "/ranking_service.ranking_service/SetUserGameScore"
|
||||
RankingService_GetRankingList_FullMethodName = "/ranking_service.ranking_service/GetRankingList"
|
||||
RankingService_AddUserGameScore_FullMethodName = "/ranking_service.ranking_service/AddUserGameScore"
|
||||
RankingService_RemoveRanking_FullMethodName = "/ranking_service.ranking_service/RemoveRanking"
|
||||
)
|
||||
|
||||
// RankingServiceClient is the client API for RankingService service.
|
||||
@ -31,6 +33,8 @@ type RankingServiceClient interface {
|
||||
Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
SetUserGameScore(ctx context.Context, in *SetUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
GetRankingList(ctx context.Context, in *GetRankingListRequest, opts ...grpc.CallOption) (*GetRankingListResponse, error)
|
||||
AddUserGameScore(ctx context.Context, in *AddUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
RemoveRanking(ctx context.Context, in *RemoveRankingRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
}
|
||||
|
||||
type rankingServiceClient struct {
|
||||
@ -71,6 +75,26 @@ func (c *rankingServiceClient) GetRankingList(ctx context.Context, in *GetRankin
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *rankingServiceClient) AddUserGameScore(ctx context.Context, in *AddUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BaseResult)
|
||||
err := c.cc.Invoke(ctx, RankingService_AddUserGameScore_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *rankingServiceClient) RemoveRanking(ctx context.Context, in *RemoveRankingRequest, opts ...grpc.CallOption) (*BaseResult, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BaseResult)
|
||||
err := c.cc.Invoke(ctx, RankingService_RemoveRanking_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// RankingServiceServer is the server API for RankingService service.
|
||||
// All implementations must embed UnimplementedRankingServiceServer
|
||||
// for forward compatibility.
|
||||
@ -78,6 +102,8 @@ type RankingServiceServer interface {
|
||||
Ping(context.Context, *Request) (*Response, error)
|
||||
SetUserGameScore(context.Context, *SetUserGameScoreRequest) (*BaseResult, error)
|
||||
GetRankingList(context.Context, *GetRankingListRequest) (*GetRankingListResponse, error)
|
||||
AddUserGameScore(context.Context, *AddUserGameScoreRequest) (*BaseResult, error)
|
||||
RemoveRanking(context.Context, *RemoveRankingRequest) (*BaseResult, error)
|
||||
mustEmbedUnimplementedRankingServiceServer()
|
||||
}
|
||||
|
||||
@ -97,6 +123,12 @@ func (UnimplementedRankingServiceServer) SetUserGameScore(context.Context, *SetU
|
||||
func (UnimplementedRankingServiceServer) GetRankingList(context.Context, *GetRankingListRequest) (*GetRankingListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetRankingList not implemented")
|
||||
}
|
||||
func (UnimplementedRankingServiceServer) AddUserGameScore(context.Context, *AddUserGameScoreRequest) (*BaseResult, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddUserGameScore not implemented")
|
||||
}
|
||||
func (UnimplementedRankingServiceServer) RemoveRanking(context.Context, *RemoveRankingRequest) (*BaseResult, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RemoveRanking not implemented")
|
||||
}
|
||||
func (UnimplementedRankingServiceServer) mustEmbedUnimplementedRankingServiceServer() {}
|
||||
func (UnimplementedRankingServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@ -172,6 +204,42 @@ func _RankingService_GetRankingList_Handler(srv interface{}, ctx context.Context
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _RankingService_AddUserGameScore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddUserGameScoreRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RankingServiceServer).AddUserGameScore(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: RankingService_AddUserGameScore_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RankingServiceServer).AddUserGameScore(ctx, req.(*AddUserGameScoreRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _RankingService_RemoveRanking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RemoveRankingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RankingServiceServer).RemoveRanking(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: RankingService_RemoveRanking_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RankingServiceServer).RemoveRanking(ctx, req.(*RemoveRankingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// RankingService_ServiceDesc is the grpc.ServiceDesc for RankingService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -191,6 +259,14 @@ var RankingService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetRankingList",
|
||||
Handler: _RankingService_GetRankingList_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddUserGameScore",
|
||||
Handler: _RankingService_AddUserGameScore_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RemoveRanking",
|
||||
Handler: _RankingService_RemoveRanking_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "ranking_service.proto",
|
||||
|
@ -45,10 +45,26 @@ message BaseResult {
|
||||
string error_msg = 2; // 错误信息
|
||||
}
|
||||
|
||||
message AddUserGameScoreRequest{
|
||||
uint32 type = 1;
|
||||
uint32 appId = 2;
|
||||
uint32 userId = 3;
|
||||
uint32 score = 4;
|
||||
}
|
||||
|
||||
message RemoveRankingRequest{
|
||||
uint32 appId = 1;
|
||||
uint32 type = 2;
|
||||
}
|
||||
|
||||
service ranking_service {
|
||||
rpc Ping(Request) returns(Response);
|
||||
|
||||
rpc SetUserGameScore (SetUserGameScoreRequest) returns (BaseResult);
|
||||
|
||||
rpc GetRankingList (GetRankingListRequest) returns (GetRankingListResponse);
|
||||
|
||||
rpc AddUserGameScore(AddUserGameScoreRequest) returns(BaseResult);
|
||||
|
||||
rpc RemoveRanking(RemoveRankingRequest) returns(BaseResult);
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
AddUserGameScoreRequest = ranking.AddUserGameScoreRequest
|
||||
BaseResult = ranking.BaseResult
|
||||
GetRankingListRequest = ranking.GetRankingListRequest
|
||||
GetRankingListResponse = ranking.GetRankingListResponse
|
||||
RankingList = ranking.RankingList
|
||||
RemoveRankingRequest = ranking.RemoveRankingRequest
|
||||
Request = ranking.Request
|
||||
Response = ranking.Response
|
||||
SetUserGameScoreRequest = ranking.SetUserGameScoreRequest
|
||||
@ -26,6 +28,8 @@ type (
|
||||
Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
SetUserGameScore(ctx context.Context, in *SetUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
GetRankingList(ctx context.Context, in *GetRankingListRequest, opts ...grpc.CallOption) (*GetRankingListResponse, error)
|
||||
AddUserGameScore(ctx context.Context, in *AddUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
RemoveRanking(ctx context.Context, in *RemoveRankingRequest, opts ...grpc.CallOption) (*BaseResult, error)
|
||||
}
|
||||
|
||||
defaultRankingService struct {
|
||||
@ -53,3 +57,13 @@ func (m *defaultRankingService) GetRankingList(ctx context.Context, in *GetRanki
|
||||
client := ranking.NewRankingServiceClient(m.cli.Conn())
|
||||
return client.GetRankingList(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultRankingService) AddUserGameScore(ctx context.Context, in *AddUserGameScoreRequest, opts ...grpc.CallOption) (*BaseResult, error) {
|
||||
client := ranking.NewRankingServiceClient(m.cli.Conn())
|
||||
return client.AddUserGameScore(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultRankingService) RemoveRanking(ctx context.Context, in *RemoveRankingRequest, opts ...grpc.CallOption) (*BaseResult, error) {
|
||||
client := ranking.NewRankingServiceClient(m.cli.Conn())
|
||||
return client.RemoveRanking(ctx, in, opts...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user