88 lines
4.2 KiB
Go
88 lines
4.2 KiB
Go
package gameclient
|
||
|
||
import (
|
||
"context"
|
||
|
||
gamev1 "hyapp.local/api/proto/game/v1"
|
||
|
||
"google.golang.org/grpc"
|
||
)
|
||
|
||
// Client 是 admin-server 管理游戏平台和目录配置的最小 gRPC 依赖。
|
||
type Client interface {
|
||
ListPlatforms(ctx context.Context, req *gamev1.ListPlatformsRequest) (*gamev1.ListPlatformsResponse, error)
|
||
UpsertPlatform(ctx context.Context, req *gamev1.UpsertPlatformRequest) (*gamev1.PlatformResponse, error)
|
||
ListCatalog(ctx context.Context, req *gamev1.ListCatalogRequest) (*gamev1.ListCatalogResponse, error)
|
||
UpsertCatalog(ctx context.Context, req *gamev1.UpsertCatalogRequest) (*gamev1.CatalogResponse, error)
|
||
SetGameStatus(ctx context.Context, req *gamev1.SetGameStatusRequest) (*gamev1.CatalogResponse, error)
|
||
DeleteCatalog(ctx context.Context, req *gamev1.DeleteCatalogRequest) (*gamev1.DeleteCatalogResponse, error)
|
||
ListSelfGames(ctx context.Context, req *gamev1.ListSelfGamesRequest) (*gamev1.ListSelfGamesResponse, error)
|
||
UpdateDiceConfig(ctx context.Context, req *gamev1.UpdateDiceConfigRequest) (*gamev1.DiceConfigResponse, error)
|
||
AdjustDicePool(ctx context.Context, req *gamev1.AdjustDicePoolRequest) (*gamev1.AdjustDicePoolResponse, error)
|
||
ListDiceRobots(ctx context.Context, req *gamev1.ListDiceRobotsRequest) (*gamev1.ListDiceRobotsResponse, error)
|
||
RegisterDiceRobots(ctx context.Context, req *gamev1.RegisterDiceRobotsRequest) (*gamev1.RegisterDiceRobotsResponse, error)
|
||
SetDiceRobotStatus(ctx context.Context, req *gamev1.SetDiceRobotStatusRequest) (*gamev1.DiceRobotResponse, error)
|
||
DeleteDiceRobot(ctx context.Context, req *gamev1.DeleteDiceRobotRequest) (*gamev1.DeleteDiceRobotResponse, error)
|
||
}
|
||
|
||
type GRPCClient struct {
|
||
client gamev1.GameAdminServiceClient
|
||
}
|
||
|
||
func NewGRPC(conn grpc.ClientConnInterface) *GRPCClient {
|
||
return &GRPCClient{client: gamev1.NewGameAdminServiceClient(conn)}
|
||
}
|
||
|
||
func (c *GRPCClient) ListPlatforms(ctx context.Context, req *gamev1.ListPlatformsRequest) (*gamev1.ListPlatformsResponse, error) {
|
||
return c.client.ListPlatforms(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) UpsertPlatform(ctx context.Context, req *gamev1.UpsertPlatformRequest) (*gamev1.PlatformResponse, error) {
|
||
return c.client.UpsertPlatform(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) ListCatalog(ctx context.Context, req *gamev1.ListCatalogRequest) (*gamev1.ListCatalogResponse, error) {
|
||
return c.client.ListCatalog(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) UpsertCatalog(ctx context.Context, req *gamev1.UpsertCatalogRequest) (*gamev1.CatalogResponse, error) {
|
||
return c.client.UpsertCatalog(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) SetGameStatus(ctx context.Context, req *gamev1.SetGameStatusRequest) (*gamev1.CatalogResponse, error) {
|
||
return c.client.SetGameStatus(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) DeleteCatalog(ctx context.Context, req *gamev1.DeleteCatalogRequest) (*gamev1.DeleteCatalogResponse, error) {
|
||
return c.client.DeleteCatalog(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) ListSelfGames(ctx context.Context, req *gamev1.ListSelfGamesRequest) (*gamev1.ListSelfGamesResponse, error) {
|
||
return c.client.ListSelfGames(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) UpdateDiceConfig(ctx context.Context, req *gamev1.UpdateDiceConfigRequest) (*gamev1.DiceConfigResponse, error) {
|
||
return c.client.UpdateDiceConfig(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) AdjustDicePool(ctx context.Context, req *gamev1.AdjustDicePoolRequest) (*gamev1.AdjustDicePoolResponse, error) {
|
||
return c.client.AdjustDicePool(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) ListDiceRobots(ctx context.Context, req *gamev1.ListDiceRobotsRequest) (*gamev1.ListDiceRobotsResponse, error) {
|
||
return c.client.ListDiceRobots(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) RegisterDiceRobots(ctx context.Context, req *gamev1.RegisterDiceRobotsRequest) (*gamev1.RegisterDiceRobotsResponse, error) {
|
||
return c.client.RegisterDiceRobots(ctx, req)
|
||
}
|
||
|
||
func (c *GRPCClient) SetDiceRobotStatus(ctx context.Context, req *gamev1.SetDiceRobotStatusRequest) (*gamev1.DiceRobotResponse, error) {
|
||
return c.client.SetDiceRobotStatus(ctx, req)
|
||
}
|
||
|
||
// DeleteDiceRobot 透传后台删除机器人登记 RPC;admin-server 不直接操作 game-service 的机器人表。
|
||
func (c *GRPCClient) DeleteDiceRobot(ctx context.Context, req *gamev1.DeleteDiceRobotRequest) (*gamev1.DeleteDiceRobotResponse, error) {
|
||
return c.client.DeleteDiceRobot(ctx, req)
|
||
}
|