chore: 补充后端核心模块的中文注释
This commit is contained in:
@@ -23,7 +23,7 @@ func DeclareDLX(ch *amqp.Channel, queueName string) error {
|
||||
}
|
||||
dlxQueue := queueName + ".dlx"
|
||||
_, err := ch.QueueDeclare(
|
||||
dlxQueue, true, false, false, false, nil,
|
||||
dlxQueue, true, false, false, false, nil, // 死信队列不设置 DLX
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -17,8 +17,8 @@ const (
|
||||
likeQueue = "like.events"
|
||||
likeBindingKey = "like.*"
|
||||
|
||||
likeLikeRK = "like.like"
|
||||
likeUnlikeRK = "like.unlike"
|
||||
likeLikeRK = "like.like" // 点赞路由键
|
||||
likeUnlikeRK = "like.unlike" // 取消点赞路由键
|
||||
)
|
||||
|
||||
type LikeEvent struct {
|
||||
|
||||
@@ -69,12 +69,12 @@ func DeclareTopic(ch *amqp.Channel, exchange string, queue string, bindingKey st
|
||||
}
|
||||
|
||||
q, err := ch.QueueDeclare(
|
||||
queue,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
amqp.Table{"x-dead-letter-exchange": DLXExchange},
|
||||
queue, // 队列名称
|
||||
true, // 持久化
|
||||
false, // autoDelete 是否在未使用时自动删除
|
||||
false, // exclusive 是否排他(允许多个消费者共享)
|
||||
false, // noWait 是否不等待 broker 确认
|
||||
amqp.Table{"x-dead-letter-exchange": DLXExchange}, // 死信交换机
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -84,8 +84,8 @@ func DeclareTopic(ch *amqp.Channel, exchange string, queue string, bindingKey st
|
||||
q.Name,
|
||||
bindingKey,
|
||||
exchange,
|
||||
false,
|
||||
nil,
|
||||
false, // noWait
|
||||
nil, // args
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -107,10 +107,10 @@ func PublishJSON(ctx context.Context, ch *amqp.Channel, exchange string, routing
|
||||
return err
|
||||
}
|
||||
return ch.PublishWithContext(ctx, exchange, routingKey, false, false, amqp.Publishing{
|
||||
ContentType: "application/json",
|
||||
DeliveryMode: amqp.Persistent,
|
||||
Timestamp: time.Now(),
|
||||
Body: b,
|
||||
ContentType: "application/json", // 消息格式
|
||||
DeliveryMode: amqp.Persistent, // 消息持久化到磁盘, 值为 1 则不持久化, 值为 2 则持久化, amqp.Presistent 为 2
|
||||
Timestamp: time.Now(), // 消息产生的时间戳
|
||||
Body: b, // 实际消息内容(JSON字节)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user