unity容器监听
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.2 KiB

package room
import (
"context"
v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v1"
k8s_client "git.gz.internal.jumaiyx.cn/pkg/k8s-client"
"git.gz.internal.jumaiyx.cn/pkg/kubediscovery"
"git.gz.internal.jumaiyx.cn/pkg/log"
)
type RoomService struct {
client v1.RoomClient
log log.Logger
}
func NewRoomService(log log.Logger) (*RoomService, error) {
discovery, err := kubediscovery.Discovery(context.TODO(), log, "room-service", kubediscovery.Namespace(k8s_client.DevNamespace))
if err != nil {
log.Errorf("Connect room service failed:%v", err)
return nil, err
}
client := v1.NewRoomClient(discovery)
return &RoomService{client: client, log: log}, nil
}
func (ser *RoomService) GetList(ctx context.Context, req *v1.ListRoomRequest) (*v1.ListRoomReply, error) {
room, err := ser.client.ListRoom(ctx, req)
if err != nil {
ser.log.Errorf("Get room list failed:%v", err)
return nil, err
}
return room, nil
}
func (ser *RoomService) GetRoom(ctx context.Context, req *v1.GetRoomRequest) (*v1.GetRoomReply, error) {
room, err := ser.client.GetRoom(ctx, req)
if err != nil {
ser.log.Errorf("Get room list failed:%v", err)
return nil, err
}
return room, nil
}