chore: 补充后端核心模块的中文注释

This commit is contained in:
2026-07-15 11:54:01 +08:00
parent e3c68dd6d3
commit ffd9b0c8f0
12 changed files with 70 additions and 39 deletions

View File

@@ -17,8 +17,8 @@ import (
"syscall"
"time"
amqp "github.com/rabbitmq/amqp091-go"
"github.com/joho/godotenv"
amqp "github.com/rabbitmq/amqp091-go"
"gorm.io/gorm"
)
@@ -40,6 +40,7 @@ const (
popularityBindingKey = "video.popularity.*"
)
// 带重试机制的基础设施连接函数
func connectWithRetry(name string, maxRetries int, fn func() error) {
for i := 0; i < maxRetries; i++ {
if err := fn(); err == nil {
@@ -55,7 +56,7 @@ func connectWithRetry(name string, maxRetries int, fn func() error) {
log.Fatalf("%s: 超过最大重试次数", name)
}
// runWorkerWithRetry 为每个 Worker 创建独立 Channel断开后自动重连
// runWorkerWithRetry 为每个 Worker 创建独立 Channel 并设置 QoS,断开后自动重连
func runWorkerWithRetry(ctx context.Context, name string, conn *amqp.Connection, fn func(*amqp.Channel) error) {
for {
select {