google-cloudevents-go icon indicating copy to clipboard operation
google-cloudevents-go copied to clipboard

Add support for Pub/Sub

Open grayside opened this issue 3 years ago • 1 comments

Current Behavior

Pub/Sub is suppressed from the code generation process in generate-code.sh because Pub/Sub messages are incompatible with protojson parsing. This is because Pub/Sub messages include duplicate fields message_id/messageId, and publish_time/publishTime, which the protobuf spec indicates is invalid.

Expected Behavior

All Event Sources have type libraries.

Approach

Add a custom function that can be used to pre-process Pub/Sub payloads before unmarshalling.

We already have a function in the repository that can facilitate this that was put in place to enable testing:

https://github.com/googleapis/google-cloudevents-go/blob/322c786abef2dfa47cce9a2d082ed83e47f5b10e/internal/testhelper/prepare.go#L11-L27

  • Move this function to the public API, preferably into the pubsubdata package. This will require a copying/templating process.
  • Unblock Pub/Sub from code generation
  • Update the code generator to use this function instead of the internal/testheper package

https://github.com/googleapis/google-cloudevents-go/blob/322c786abef2dfa47cce9a2d082ed83e47f5b10e/generators/protoc-gen-go-googlecetypes/generator.go#L146-L147

grayside avatar Jan 31 '23 19:01 grayside

@grayside I noticed this issue open but couldn't figure out how people are meant to parse pub/sub if not with this library? Is there a different library that should be used?

ejcx avatar Mar 08 '23 06:03 ejcx