// Package integration 定义 room-service 到外部服务的接口边界。 package integration import ( "context" activityv1 "hyapp.local/api/proto/activity/v1" roomeventsv1 "hyapp.local/api/proto/events/room/v1" walletv1 "hyapp.local/api/proto/wallet/v1" "hyapp/pkg/tencentim" ) // WalletClient 抽象 room-service 对 wallet-service 的同步扣费依赖。 type WalletClient interface { // DebitGift 执行送礼扣费;失败时 room-service 不进入 Room Cell 状态提交。 DebitGift(ctx context.Context, req *walletv1.DebitGiftRequest) (*walletv1.DebitGiftResponse, error) // BatchDebitGift 在 wallet-service 单事务内结算多目标送礼;任一目标失败时整批失败。 BatchDebitGift(ctx context.Context, req *walletv1.BatchDebitGiftRequest) (*walletv1.BatchDebitGiftResponse, error) // GrantResourceGroup 发放宝箱奖励资源组;命令 ID 必须由 room-service 按宝箱结算事实生成。 GrantResourceGroup(ctx context.Context, req *walletv1.GrantResourceGroupRequest) (*walletv1.ResourceGrantResponse, error) } // LuckyGiftClient 抽象 room-service 对 activity-service 幸运礼物抽奖边界的同步依赖。 type LuckyGiftClient interface { // CheckLuckyGift 在扣费前确认奖池规则可用;失败时不能扣费。 CheckLuckyGift(ctx context.Context, req *activityv1.CheckLuckyGiftRequest) (*activityv1.CheckLuckyGiftResponse, error) // ExecuteLuckyGiftDraw 在钱包扣费成功后按 command_id 幂等落抽奖事实。 ExecuteLuckyGiftDraw(ctx context.Context, req *activityv1.ExecuteLuckyGiftDrawRequest) (*activityv1.ExecuteLuckyGiftDrawResponse, error) } // RoomEventPublisher 保留腾讯云 IM 直接桥接能力;房间命令主链路不再调用它。 type RoomEventPublisher interface { // EnsureRoomGroup 确保房间在腾讯云 IM 中有对应群组。 EnsureRoomGroup(ctx context.Context, roomID string, ownerUserID int64) error // PublishRoomEvent 把房间系统事件推给腾讯云 IM,当前只供异步边界复用。 PublishRoomEvent(ctx context.Context, event tencentim.RoomEvent) error } // RTCUserRemover 抽象 room-service 对腾讯 RTC 实时房间的服务端踢人能力。 // 连接态仍在腾讯 RTC,Room Cell 只在状态提交后触发这个外部副作用。 type RTCUserRemover interface { RemoveUserByStrRoomID(ctx context.Context, roomID string, userID int64) error } // OutboxPublisher 抽象 outbox worker 对外部消费者的异步投递。 type OutboxPublisher interface { // PublishOutboxEvent 投递 protobuf outbox 信封,失败由 room_outbox 转为 retryable 状态重试。 PublishOutboxEvent(ctx context.Context, envelope *roomeventsv1.EventEnvelope) error } // RoomTreasureOpenSchedule 是 RoomTreasureCountdownStarted 派生出的延迟开箱唤醒任务。 type RoomTreasureOpenSchedule struct { AppCode string RoomID string BoxID string Level int32 OpenAtMS int64 ResetAtMS int64 CommandID string } // RoomTreasureOpenScheduler 抽象“到 open_at_ms 唤醒 room-service”的外部延迟通道。 type RoomTreasureOpenScheduler interface { // ScheduleRoomTreasureOpen 只负责安排唤醒;真正开箱仍由 room-service 命令链路校验并提交。 ScheduleRoomTreasureOpen(ctx context.Context, schedule RoomTreasureOpenSchedule) error }