Go pub子库中PullWait的行为?

我目前正在尝试使用Google Cloud PubSub的
go library并同时查阅文档.

我的代码测试PullWait函数的行为,根据documentation执行以下操作:

PullWait pulls messages from the subscription. If there are not enough messages left in the subscription queue, it will block until at least n number of messages arrive or timeout occurs, and n could not be larger than 100.

但是,我的测试显示,无论指定的值n如何,我总是立即收到m消息,其中m <= n.我在这里错过了什么吗? 使用的代码摘录:

msgs, err := pubsub.PullWait(subCtx, subscriptionName, 50)
if err != nil {
    log.Printf("Error when trying to pull messages from subscription: %v", err)
} else {
    for _, msg := range msgs {
        str := string(msg.Data)
        log.Printf("Message [msg-id=%s]: '%v'", msg.ID, str)

        if err := pubsub.Ack(ctx, subscriptionName, msg.AckID); err != nil {
            log.Printf("Unable to acknowledge message [ack-id=%s]: %v", msg.AckID, err)
        }
    }
}

并且当时队列中只包含一条消息,该消息立即返回给我:

2015/11/04 11:45:15 Message [msg-id=2384294654226]: ‘hello world my friend’

最佳答案 事实证明文档是不正确的. PullWait使用returnImmediately设置为false调用底层的
pull method,这意味着它等待接收至少一条消息(但不超过n条消息).我已提交了进行更正的请求.

点赞