-
Notifications
You must be signed in to change notification settings - Fork 235
Open
Description
Since the change in #976 it seems that Attributes property needs to be defined on the output message prior to calling WritePubSubMessage
previously this wasn't strictly needed (at least it didn't exist this way in our code).
Which raises the question, should I need to have an Attributes
field prior to calling WritePubSubMessage()
or should it work with an empty message?
Alternatively is there a proper way that I should instantiate a pubsub.Message
other than how I have below?
Broken:
import("github.com/cloudevents/sdk-go/v2/binding")
func writeMsg(ctx context.Context, in binding.Message) {
msg := &pubsub.Message{}
err := WritePubSubMessage(ctx, in, msg); // Results in Panic
//Do something with msg
}
Working:
import("github.com/cloudevents/sdk-go/v2/binding")
func writeMsg(ctx context.Context, in binding.Message) {
msg := &pubsub.Message{
Attributes: AttributesFrom(ctx),
}
err := WritePubSubMessage(ctx, in, msg); // Does not result in Panic
//Do something with msg
}
Metadata
Metadata
Assignees
Labels
No labels