This repository was archived by the owner on Mar 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
samples: publish with ordering keys #156
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
25022f1
samples: add samples for publish with ordering keys
anguillanneuf c3d2367
update readme
anguillanneuf 8b6b650
add regional endpoint
anguillanneuf 4c53b33
Merge branch 'master' into samples-ordering
anguillanneuf 0aacc25
remove extra white space
anguillanneuf 08e6974
fix function signature in test
anguillanneuf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,28 @@ def create_push_subscription(project_id, topic_id, subscription_id, endpoint): | |
| # [END pubsub_create_push_subscription] | ||
|
|
||
|
|
||
| def create_subscription_with_ordering(project_id, topic_id, subscription_id): | ||
| """Create a subscription with dead letter policy.""" | ||
| # [START pubsub_enable_subscription_ordering] | ||
| from google.cloud import pubsub_v1 | ||
|
|
||
| # TODO(developer): Choose an existing topic. | ||
| # project_id = "your-project-id" | ||
| # topic_id = "your-topic-id" | ||
| # subscription_id = "your-subscription-id" | ||
|
|
||
| subscriber = pubsub_v1.SubscriberClient() | ||
| topic_path = subscriber.topic_path(project_id, topic_id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a massive PR! Thank you for the heads-up! I will aim to merge this one after that one and the changes are in. |
||
| subscription_path = subscriber.subscription_path(project_id, subscription_id) | ||
|
|
||
| with subscriber: | ||
| subscription = subscriber.create_subscription( | ||
| subscription_path, topic_path, enable_message_ordering=True | ||
| ) | ||
| print("Created subscription with ordering: {}".format(subscription)) | ||
| # [END pubsub_enable_subscription_ordering] | ||
|
|
||
|
|
||
| def delete_subscription(project_id, subscription_id): | ||
| """Deletes an existing Pub/Sub topic.""" | ||
| # [START pubsub_delete_subscription] | ||
|
|
@@ -654,6 +676,12 @@ def callback(message): | |
| create_push_parser.add_argument("subscription_id") | ||
| create_push_parser.add_argument("endpoint") | ||
|
|
||
| create_subscription_with_ordering_parser = subparsers.add_parser( | ||
| "create-with-ordering", help=create_subscription_with_ordering.__doc__ | ||
| ) | ||
| create_subscription_with_ordering_parser.add_argument("topic_id") | ||
| create_subscription_with_ordering_parser.add_argument("subscription_id") | ||
|
|
||
| delete_parser = subparsers.add_parser("delete", help=delete_subscription.__doc__) | ||
| delete_parser.add_argument("subscription_id") | ||
|
|
||
|
|
@@ -746,6 +774,10 @@ def callback(message): | |
| create_push_subscription( | ||
| args.project_id, args.topic_id, args.subscription_id, args.endpoint, | ||
| ) | ||
| elif args.command == "create-with-ordering": | ||
| create_subscription_with_ordering( | ||
| args.project_id, args.topic_id, args.subscription_id | ||
| ) | ||
| elif args.command == "delete": | ||
| delete_subscription(args.project_id, args.subscription_id) | ||
| elif args.command == "update-push": | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.