Skip to content

subscription.pull() should return a list of objects rather than tuples. #913

@jgeewax

Description

@jgeewax

Copied from comments in #910

Currently, when pulling messages via a subscription, I'd write:

received = subscription.pull()
for ack_id, message in received:
  print ack_id
  print message['attr1']
  print message.data  # ?
  print message.id  # ?

I think it'd be better to have the return value be an iterable of some more complex object (maybe a pubsub.Message?):

messages = subscription.pull()
for message in messages:
  print message.get_ack_id()  # ReceivedMessage.ackId (string)
  print message['attr1']  # PubsubMessage.attributes (dict)
  print message.get_data()  # PubsubMessage.data (bytes)
  print message.get_id()  # corresponds to PubsubMessage.messageId (string)

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions