robot-service
robot-service 是后端独立机器人账号池服务,当前拆成两个域:
game-robot:自研游戏机器人池,给game-service匹配机器人补位使用。room-robot:房间机器人账号池,首版只管理账号可用性,不直接操作 Room Cell。
边界
- robot-service 只保存“哪些真实用户可以作为机器人”的登记事实。
- 用户资料、头像、昵称仍由
user-service/likei用户库负责。 - 游戏局、结算、奖池、forced_result 仍由
game-service负责。 - 房间进入、离开、麦位、IM 事件仍由
room-service负责。
数据库
新逻辑使用独立库:
hyapp_robot.robot_game_robotshyapp_robot.robot_room_robotshyapp_robot.robot_service_migrations
旧库旧表保留不删除:
hyapp_game.game_self_game_robots
启动时如果 legacy_game_database 配置为 hyapp_game,服务会把旧 game_self_game_robots 聚合迁移到 robot_game_robots。迁移完成后会写入 robot_service_migrations,之后不会再用旧表覆盖新表。
配置
本地配置:
grpc_addr: ":13011"
health_http_addr: ":13111"
mysql_dsn: "hyapp:hyapp@tcp(127.0.0.1:23306)/hyapp_robot?parseTime=true&charset=utf8mb4&loc=UTC&multiStatements=true"
legacy_game_database: "hyapp_game"
Docker 配置使用 mysql:3306,线上配置使用 ROBOT_MYSQL_DSN。
RPC
Proto 文件:
api/proto/robot/v1/robot.proto
服务:
GameRobotServiceRoomRobotService
PickGameRobot 接收 exclude_user_ids,由 game-service 传入当前局参与者,robot-service 不再读取游戏局表来排除用户。
本地运行
./scripts/apply-local-mysql-initdb.sh
make up robot
健康检查:
curl http://127.0.0.1:13111/healthz/ready
验证
PATH="/Users/hy/go/bin:$PATH" make proto
go test ./services/robot-service/...
go test ./services/game-service/internal/service/dice ./services/game-service/internal/client ./services/game-service/internal/app
docker compose config