add comments

This commit is contained in:
Edward 2020-05-08 20:33:06 +08:00 committed by GitHub
parent 085c2e8f4b
commit acb36d081b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,13 +11,14 @@ import (
//////////////////////////////// ////////////////////////////////
//通常意义上是,连接消息队列之后就可以发送消息 //通常意义上是,连接消息队列之后就可以发送消息
//当订阅著之后才会收到相关Topic消息的推送 //当订阅著之后才会收到相关Topic消息的推送
//当前,省略连接队列的步骤和操作代码
//////////////////////////////// ////////////////////////////////
func TestMessageSubAndPubWithTopic(t *testing.T) { func TestMessageSubAndPubWithTopic(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
topicName := "seeking passengers" topicName := "seeking passengers"
//假设评估 //假设消息队列已经收到数据加下来由topic处理
topic := Topic{ topic := Topic{
Name: topicName, Name: topicName,
UserQueueSize: 5, UserQueueSize: 5,
@ -26,8 +27,8 @@ func TestMessageSubAndPubWithTopic(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
wg.Add(1) wg.Add(1)
//user 1
//user 1
//用户tom订阅拼车消息,订阅的是车主发布的拼车消息 //用户tom订阅拼车消息,订阅的是车主发布的拼车消息
if subScriberTom, ok := topic.Subscribe(123, topicName); ok { if subScriberTom, ok := topic.Subscribe(123, topicName); ok {
@ -52,6 +53,7 @@ func TestMessageSubAndPubWithTopic(t *testing.T) {
} }
wg.Add(1) wg.Add(1)
//订阅成功了 //订阅成功了
//发送一个消息 //发送一个消息