GoogleCloudPlatform / golang-samples

Sample apps and code written for Google Cloud in the Go programming language.
Apache License 2.0
4.32k stars 1.75k forks source link

fix(pubsub): add locational endpoint for exactly once sample #4334

Closed hongalex closed 3 months ago

hongalex commented 3 months ago

Description

Exactly once delivery is best set with a locational endpoint. This adds the WithEndpoint option to the exactly once sample, and fixes the comments for ordering samples.


When you run your application within Google Cloud, it typically connects to the Pub/Sub endpoint in the same region by default. Therefore, running your application in a single region within Google Cloud generally ensures you are interacting with a single region.

If you are running your publisher application outside of Google Cloud or in multiple regions, you can guarantee you are connecting to a single region using a locational endpoint when configuring your Pub/Sub client. All location endpoints for Pub/Sub point to single regions. For a list of all locational endpoints for Pub/Sub, see List of locational endpoints.

hongalex commented 2 months ago

Thanks for the review!