The docs have this example:
publisher=pubsub.PublisherClient()
topic='projects/{project_id}/topics/{topic}'.format(
project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
topic='MY_TOPIC_NAME', # Set this to something appropriate.
)
publisher.create_topic()
publisher.publish(topic, b'My first message!', spam='eggs')should it be:
publisher=pubsub.PublisherClient()
topic_path='projects/{project_id}/topics/{topic}'.format(
project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
topic='MY_TOPIC_NAME', # Set this to something appropriate.
)
topic=publisher.create_topic(topic_path)
publisher.publish(topic, b'My first message!', spam='eggs')main questions:
- how does publisher.create_topic() know what topic if we don't tell it
- is there still a a topic object as there was before 0.28.0?
- can we just create a topic regardless whether it is already there? The old code (pre 0.28.0) was doing:
client=pubsub.Client()
topic=client.topic(topic_name)
ifnottopic.exists():
topic.create()
The docs have this example:
should it be:
main questions: