【发布时间】:2021-12-31 16:20:18
【问题描述】:
我正在尝试访问触发我的 Golang 函数的 Pub/Sub 消息的 messageId。为此,我正在尝试从 Cloud Functions documentation 修改 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"`
}
函数编译正常,但 MessageID 值为空。更改类型没有帮助。 我想知道是否有办法从函数中获取触发消息 Id。或者可能根本没有传递给函数?
【问题讨论】:
标签: go google-cloud-functions google-cloud-pubsub