-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
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)
if not topic.exists():
topic.create()Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.