Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`. - Added new API server implementations for objectstory, player, and shop services. - Introduced configuration files for new APIs in `etc/*.yaml`. - Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`. - Removed unused user update handler and user API files. - Added utility functions for context management and HTTP header parsing. - Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
@@ -19,17 +19,17 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Public_AddGames_FullMethodName = "/pb.public/AddGames"
|
||||
Public_UpdateGames_FullMethodName = "/pb.public/UpdateGames"
|
||||
Public_DelGames_FullMethodName = "/pb.public/DelGames"
|
||||
Public_GetGamesById_FullMethodName = "/pb.public/GetGamesById"
|
||||
Public_SearchGames_FullMethodName = "/pb.public/SearchGames"
|
||||
GameService_AddGames_FullMethodName = "/pb.GameService/AddGames"
|
||||
GameService_UpdateGames_FullMethodName = "/pb.GameService/UpdateGames"
|
||||
GameService_DelGames_FullMethodName = "/pb.GameService/DelGames"
|
||||
GameService_GetGamesById_FullMethodName = "/pb.GameService/GetGamesById"
|
||||
GameService_SearchGames_FullMethodName = "/pb.GameService/SearchGames"
|
||||
)
|
||||
|
||||
// PublicClient is the client API for Public service.
|
||||
// GameServiceClient is the client API for GameService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type PublicClient interface {
|
||||
type GameServiceClient interface {
|
||||
// -----------------------games-----------------------
|
||||
AddGames(ctx context.Context, in *AddGamesReq, opts ...grpc.CallOption) (*AddGamesResp, error)
|
||||
UpdateGames(ctx context.Context, in *UpdateGamesReq, opts ...grpc.CallOption) (*UpdateGamesResp, error)
|
||||
@@ -38,236 +38,236 @@ type PublicClient interface {
|
||||
SearchGames(ctx context.Context, in *SearchGamesReq, opts ...grpc.CallOption) (*SearchGamesResp, error)
|
||||
}
|
||||
|
||||
type publicClient struct {
|
||||
type gameServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewPublicClient(cc grpc.ClientConnInterface) PublicClient {
|
||||
return &publicClient{cc}
|
||||
func NewGameServiceClient(cc grpc.ClientConnInterface) GameServiceClient {
|
||||
return &gameServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *publicClient) AddGames(ctx context.Context, in *AddGamesReq, opts ...grpc.CallOption) (*AddGamesResp, error) {
|
||||
func (c *gameServiceClient) AddGames(ctx context.Context, in *AddGamesReq, opts ...grpc.CallOption) (*AddGamesResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddGamesResp)
|
||||
err := c.cc.Invoke(ctx, Public_AddGames_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, GameService_AddGames_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *publicClient) UpdateGames(ctx context.Context, in *UpdateGamesReq, opts ...grpc.CallOption) (*UpdateGamesResp, error) {
|
||||
func (c *gameServiceClient) UpdateGames(ctx context.Context, in *UpdateGamesReq, opts ...grpc.CallOption) (*UpdateGamesResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdateGamesResp)
|
||||
err := c.cc.Invoke(ctx, Public_UpdateGames_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, GameService_UpdateGames_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *publicClient) DelGames(ctx context.Context, in *DelGamesReq, opts ...grpc.CallOption) (*DelGamesResp, error) {
|
||||
func (c *gameServiceClient) DelGames(ctx context.Context, in *DelGamesReq, opts ...grpc.CallOption) (*DelGamesResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DelGamesResp)
|
||||
err := c.cc.Invoke(ctx, Public_DelGames_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, GameService_DelGames_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *publicClient) GetGamesById(ctx context.Context, in *GetGamesByIdReq, opts ...grpc.CallOption) (*GetGamesByIdResp, error) {
|
||||
func (c *gameServiceClient) GetGamesById(ctx context.Context, in *GetGamesByIdReq, opts ...grpc.CallOption) (*GetGamesByIdResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetGamesByIdResp)
|
||||
err := c.cc.Invoke(ctx, Public_GetGamesById_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, GameService_GetGamesById_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *publicClient) SearchGames(ctx context.Context, in *SearchGamesReq, opts ...grpc.CallOption) (*SearchGamesResp, error) {
|
||||
func (c *gameServiceClient) SearchGames(ctx context.Context, in *SearchGamesReq, opts ...grpc.CallOption) (*SearchGamesResp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SearchGamesResp)
|
||||
err := c.cc.Invoke(ctx, Public_SearchGames_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, GameService_SearchGames_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PublicServer is the server API for Public service.
|
||||
// All implementations must embed UnimplementedPublicServer
|
||||
// GameServiceServer is the server API for GameService service.
|
||||
// All implementations must embed UnimplementedGameServiceServer
|
||||
// for forward compatibility.
|
||||
type PublicServer interface {
|
||||
type GameServiceServer interface {
|
||||
// -----------------------games-----------------------
|
||||
AddGames(context.Context, *AddGamesReq) (*AddGamesResp, error)
|
||||
UpdateGames(context.Context, *UpdateGamesReq) (*UpdateGamesResp, error)
|
||||
DelGames(context.Context, *DelGamesReq) (*DelGamesResp, error)
|
||||
GetGamesById(context.Context, *GetGamesByIdReq) (*GetGamesByIdResp, error)
|
||||
SearchGames(context.Context, *SearchGamesReq) (*SearchGamesResp, error)
|
||||
mustEmbedUnimplementedPublicServer()
|
||||
mustEmbedUnimplementedGameServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedPublicServer must be embedded to have
|
||||
// UnimplementedGameServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedPublicServer struct{}
|
||||
type UnimplementedGameServiceServer struct{}
|
||||
|
||||
func (UnimplementedPublicServer) AddGames(context.Context, *AddGamesReq) (*AddGamesResp, error) {
|
||||
func (UnimplementedGameServiceServer) AddGames(context.Context, *AddGamesReq) (*AddGamesResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AddGames not implemented")
|
||||
}
|
||||
func (UnimplementedPublicServer) UpdateGames(context.Context, *UpdateGamesReq) (*UpdateGamesResp, error) {
|
||||
func (UnimplementedGameServiceServer) UpdateGames(context.Context, *UpdateGamesReq) (*UpdateGamesResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateGames not implemented")
|
||||
}
|
||||
func (UnimplementedPublicServer) DelGames(context.Context, *DelGamesReq) (*DelGamesResp, error) {
|
||||
func (UnimplementedGameServiceServer) DelGames(context.Context, *DelGamesReq) (*DelGamesResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DelGames not implemented")
|
||||
}
|
||||
func (UnimplementedPublicServer) GetGamesById(context.Context, *GetGamesByIdReq) (*GetGamesByIdResp, error) {
|
||||
func (UnimplementedGameServiceServer) GetGamesById(context.Context, *GetGamesByIdReq) (*GetGamesByIdResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetGamesById not implemented")
|
||||
}
|
||||
func (UnimplementedPublicServer) SearchGames(context.Context, *SearchGamesReq) (*SearchGamesResp, error) {
|
||||
func (UnimplementedGameServiceServer) SearchGames(context.Context, *SearchGamesReq) (*SearchGamesResp, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SearchGames not implemented")
|
||||
}
|
||||
func (UnimplementedPublicServer) mustEmbedUnimplementedPublicServer() {}
|
||||
func (UnimplementedPublicServer) testEmbeddedByValue() {}
|
||||
func (UnimplementedGameServiceServer) mustEmbedUnimplementedGameServiceServer() {}
|
||||
func (UnimplementedGameServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafePublicServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to PublicServer will
|
||||
// UnsafeGameServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GameServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafePublicServer interface {
|
||||
mustEmbedUnimplementedPublicServer()
|
||||
type UnsafeGameServiceServer interface {
|
||||
mustEmbedUnimplementedGameServiceServer()
|
||||
}
|
||||
|
||||
func RegisterPublicServer(s grpc.ServiceRegistrar, srv PublicServer) {
|
||||
// If the following call panics, it indicates UnimplementedPublicServer was
|
||||
func RegisterGameServiceServer(s grpc.ServiceRegistrar, srv GameServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedGameServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Public_ServiceDesc, srv)
|
||||
s.RegisterService(&GameService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Public_AddGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _GameService_AddGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddGamesReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PublicServer).AddGames(ctx, in)
|
||||
return srv.(GameServiceServer).AddGames(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Public_AddGames_FullMethodName,
|
||||
FullMethod: GameService_AddGames_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PublicServer).AddGames(ctx, req.(*AddGamesReq))
|
||||
return srv.(GameServiceServer).AddGames(ctx, req.(*AddGamesReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Public_UpdateGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _GameService_UpdateGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateGamesReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PublicServer).UpdateGames(ctx, in)
|
||||
return srv.(GameServiceServer).UpdateGames(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Public_UpdateGames_FullMethodName,
|
||||
FullMethod: GameService_UpdateGames_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PublicServer).UpdateGames(ctx, req.(*UpdateGamesReq))
|
||||
return srv.(GameServiceServer).UpdateGames(ctx, req.(*UpdateGamesReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Public_DelGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _GameService_DelGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DelGamesReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PublicServer).DelGames(ctx, in)
|
||||
return srv.(GameServiceServer).DelGames(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Public_DelGames_FullMethodName,
|
||||
FullMethod: GameService_DelGames_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PublicServer).DelGames(ctx, req.(*DelGamesReq))
|
||||
return srv.(GameServiceServer).DelGames(ctx, req.(*DelGamesReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Public_GetGamesById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _GameService_GetGamesById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetGamesByIdReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PublicServer).GetGamesById(ctx, in)
|
||||
return srv.(GameServiceServer).GetGamesById(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Public_GetGamesById_FullMethodName,
|
||||
FullMethod: GameService_GetGamesById_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PublicServer).GetGamesById(ctx, req.(*GetGamesByIdReq))
|
||||
return srv.(GameServiceServer).GetGamesById(ctx, req.(*GetGamesByIdReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Public_SearchGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _GameService_SearchGames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SearchGamesReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PublicServer).SearchGames(ctx, in)
|
||||
return srv.(GameServiceServer).SearchGames(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Public_SearchGames_FullMethodName,
|
||||
FullMethod: GameService_SearchGames_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PublicServer).SearchGames(ctx, req.(*SearchGamesReq))
|
||||
return srv.(GameServiceServer).SearchGames(ctx, req.(*SearchGamesReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Public_ServiceDesc is the grpc.ServiceDesc for Public service.
|
||||
// GameService_ServiceDesc is the grpc.ServiceDesc for GameService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Public_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pb.public",
|
||||
HandlerType: (*PublicServer)(nil),
|
||||
var GameService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pb.GameService",
|
||||
HandlerType: (*GameServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AddGames",
|
||||
Handler: _Public_AddGames_Handler,
|
||||
Handler: _GameService_AddGames_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateGames",
|
||||
Handler: _Public_UpdateGames_Handler,
|
||||
Handler: _GameService_UpdateGames_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DelGames",
|
||||
Handler: _Public_DelGames_Handler,
|
||||
Handler: _GameService_DelGames_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetGamesById",
|
||||
Handler: _Public_GetGamesById_Handler,
|
||||
Handler: _GameService_GetGamesById_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SearchGames",
|
||||
Handler: _Public_SearchGames_Handler,
|
||||
Handler: _GameService_SearchGames_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
||||
Reference in New Issue
Block a user