小编Svy*_*rny的帖子

查找触发Cloud Function的Pub/Sub消息的messageID

我正在尝试访问触发我的 Golang 函数的 Pub/Sub 消息的 messageId。为此,我尝试修改Cloud Functions 文档中的 PubSubMessage 结构:

// PubSubMessage is the payload of a Pub/Sub event.
// See the documentation for more details:
// https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage
type PubSubMessage struct {
        Data []byte `json:"data"`
        MessageId string `json:"messageId"`
}
Run Code Online (Sandbox Code Playgroud)

该函数编译正常,但 MessageID 值变为空。更改类型没有帮助。我想知道是否有办法从函数内获取触发消息 Id。或者也许根本没有传递给函数?

go google-cloud-pubsub google-cloud-functions

3
推荐指数
1
解决办法
1452
查看次数