chamikaramj commented on a change in pull request #12806:
URL: https://github.com/apache/beam/pull/12806#discussion_r489813934
##########
File path: sdks/python/apache_beam/io/gcp/pubsub.py
##########
@@ -290,21 +290,26 @@ def __init__(self,
topic, id_label, with_attributes, timestamp_attribute)
@staticmethod
- def to_proto_str(element):
+ def message_to_proto_str(element):
# type: (PubsubMessage) -> bytes
if not isinstance(element, PubsubMessage):
raise TypeError(
'Unexpected element. Type: %s (expected: PubsubMessage), '
'value: %r' % (type(element), element))
return element._to_proto_str()
+ @staticmethod
+ def bytes_to_proto_str(element):
+ # type: (bytes) -> bytes
+ msg = pubsub.types.pubsub_pb2.PubsubMessage()
+ msg.data = element
+ return msg.SerializeToString()
+
def expand(self, pcoll):
if self.with_attributes:
Review comment:
This is fine but probably means that we'll have to keep the
with_attributes property in PubSubWritePayload to properly reconstruct the
transforms from the proto.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]