47 lines
1.8 KiB
Go
47 lines
1.8 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)
|
|
}
|
|
|
|
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)
|
|
}
|