2026-06-27 16:59:30 +08:00

71 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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)
// DebitRobotGift 扣机器人专用金币;只用于机器人房间内部展示礼物。
DebitRobotGift(ctx context.Context, req *walletv1.DebitRobotGiftRequest) (*walletv1.DebitGiftResponse, 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)
// BatchExecuteLuckyGiftDraw 一次提交多人送礼的全部目标抽奖事实,返回顺序必须和请求目标顺序一致。
BatchExecuteLuckyGiftDraw(ctx context.Context, req *activityv1.BatchExecuteLuckyGiftDrawRequest) (*activityv1.BatchExecuteLuckyGiftDrawResponse, 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 实时房间的服务端踢人能力。
// 连接态仍在腾讯 RTCRoom 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
}
// RoomRocketLaunchSchedule 是 RoomRocketIgnited 派生出的延迟发射唤醒任务。
type RoomRocketLaunchSchedule struct {
AppCode string
RoomID string
RocketID string
Level int32
LaunchAtMS int64
ResetAtMS int64
CommandID string
}
// RoomRocketLaunchScheduler 抽象“到 launch_at_ms 唤醒 room-service”的外部延迟通道。
type RoomRocketLaunchScheduler interface {
// ScheduleRoomRocketLaunch 只负责安排唤醒;真正发射仍由 room-service 命令链路校验并提交。
ScheduleRoomRocketLaunch(ctx context.Context, schedule RoomRocketLaunchSchedule) error
}