dashbitco / broadway_cloud_pub_sub

A Broadway producer for Google Cloud Pub/Sub
Apache License 2.0
70 stars 24 forks source link

Issue with v.0.9.0: no function clause matching in BroadwayCloudPubSub.PullClient.decode_message/1 #100

Closed mwilsoncoding closed 4 months ago

mwilsoncoding commented 4 months ago

Hi all,

This was recently closed as completed in https://github.com/dashbitco/broadway_cloud_pub_sub/pull/99.

I am implementing a service that publishes messages with no data to a Topic.

I would like to implement the service without having to add payloadFormat: "NONE" to my attributes map. This appears to be a convention used for Cloud Storage.

The following guards on BroadwayCloudPubSub.PullClient.decode_message/1 allow for this implementation without having to use the payloadFormat field:

defp decode_message(message) when is_map(message) and not is_map_key(message, "data"), do: message

I tested this change using the method German Velasco describes in Prying Into Elixir Dependencies.

Is it possible to update the recent implementation with the above suggestion or something similar?

I'll include a PR with this change as well in case the idea is agreeable.