From 78054682770af3b35cb0002c3c34006ec36590ef Mon Sep 17 00:00:00 2001 From: tmdiep Date: Thu, 3 Feb 2022 14:00:55 +1100 Subject: [PATCH] docs(pubsublite): update comments for regional topics (#5202) Update comments to indicate that topics may belong to a region or zone. Release-As: 1.2.2 --- pubsublite/admin.go | 36 +++++++++-------- pubsublite/config.go | 21 +++++----- pubsublite/doc.go | 11 ++++++ pubsublite/example_test.go | 56 +++++++++++++-------------- pubsublite/internal/wire/resources.go | 2 +- pubsublite/operations.go | 2 +- pubsublite/pscompat/example_test.go | 22 +++++------ pubsublite/pscompat/publisher.go | 4 +- pubsublite/pscompat/subscriber.go | 4 +- 9 files changed, 86 insertions(+), 72 deletions(-) diff --git a/pubsublite/admin.go b/pubsublite/admin.go index cec841d0c59..09964e4d88b 100644 --- a/pubsublite/admin.go +++ b/pubsublite/admin.go @@ -31,9 +31,10 @@ var ( ) // AdminClient provides admin operations for Pub/Sub Lite resources within a -// Google Cloud region. The zone component of resource paths must be within this -// region. See https://cloud.google.com/pubsub/lite/docs/locations for the list -// of zones where Pub/Sub Lite is available. +// Google Cloud region. The location (region or zone) component of resource +// paths must be within this region. +// See https://cloud.google.com/pubsub/lite/docs/locations for the list of +// regions and zones where Pub/Sub Lite is available. // // An AdminClient may be shared by multiple goroutines. type AdminClient struct { @@ -90,7 +91,7 @@ func (ac *AdminClient) UpdateTopic(ctx context.Context, config TopicConfigToUpda } // DeleteTopic deletes a topic. A valid topic path has the format: -// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func (ac *AdminClient) DeleteTopic(ctx context.Context, topic string) error { if _, err := wire.ParseTopicPath(topic); err != nil { return err @@ -99,7 +100,7 @@ func (ac *AdminClient) DeleteTopic(ctx context.Context, topic string) error { } // Topic retrieves the configuration of a topic. A valid topic path has the -// format: "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// format: "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func (ac *AdminClient) Topic(ctx context.Context, topic string) (*TopicConfig, error) { if _, err := wire.ParseTopicPath(topic); err != nil { return nil, err @@ -113,7 +114,7 @@ func (ac *AdminClient) Topic(ctx context.Context, topic string) (*TopicConfig, e // TopicPartitionCount returns the number of partitions for a topic. A valid // topic path has the format: -// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func (ac *AdminClient) TopicPartitionCount(ctx context.Context, topic string) (int, error) { if _, err := wire.ParseTopicPath(topic); err != nil { return 0, err @@ -127,7 +128,7 @@ func (ac *AdminClient) TopicPartitionCount(ctx context.Context, topic string) (i // TopicSubscriptions retrieves the list of subscription paths for a topic. // A valid topic path has the format: -// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func (ac *AdminClient) TopicSubscriptions(ctx context.Context, topic string) *SubscriptionPathIterator { if _, err := wire.ParseTopicPath(topic); err != nil { return &SubscriptionPathIterator{err: err} @@ -137,8 +138,9 @@ func (ac *AdminClient) TopicSubscriptions(ctx context.Context, topic string) *Su } } -// Topics retrieves the list of topic configs for a given project and zone. -// A valid parent path has the format: "projects/PROJECT_ID/locations/ZONE". +// Topics retrieves the list of topic configs for a given project and location +// (region or zone). A valid parent path has the format: +// "projects/PROJECT_ID/locations/LOCATION". func (ac *AdminClient) Topics(ctx context.Context, parent string) *TopicIterator { if _, err := wire.ParseLocationPath(parent); err != nil { return &TopicIterator{err: err} @@ -223,7 +225,7 @@ func (ac *AdminClient) UpdateSubscription(ctx context.Context, config Subscripti // SeekSubscription initiates an out-of-band seek for a subscription to a // specified target, which may be timestamps or named positions within the // message backlog. A valid subscription path has the format: -// "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". +// "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". // // See https://cloud.google.com/pubsub/lite/docs/seek for more information. func (ac *AdminClient) SeekSubscription(ctx context.Context, subscription string, target SeekTarget, opts ...SeekSubscriptionOption) (*SeekSubscriptionOperation, error) { @@ -240,7 +242,7 @@ func (ac *AdminClient) SeekSubscription(ctx context.Context, subscription string } // DeleteSubscription deletes a subscription. A valid subscription path has the -// format: "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". +// format: "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". func (ac *AdminClient) DeleteSubscription(ctx context.Context, subscription string) error { if _, err := wire.ParseSubscriptionPath(subscription); err != nil { return err @@ -250,7 +252,7 @@ func (ac *AdminClient) DeleteSubscription(ctx context.Context, subscription stri // Subscription retrieves the configuration of a subscription. A valid // subscription name has the format: -// "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". +// "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". func (ac *AdminClient) Subscription(ctx context.Context, subscription string) (*SubscriptionConfig, error) { if _, err := wire.ParseSubscriptionPath(subscription); err != nil { return nil, err @@ -263,8 +265,8 @@ func (ac *AdminClient) Subscription(ctx context.Context, subscription string) (* } // Subscriptions retrieves the list of subscription configs for a given project -// and zone. A valid parent path has the format: -// "projects/PROJECT_ID/locations/ZONE". +// and location (region or zone). A valid parent path has the format: +// "projects/PROJECT_ID/locations/LOCATION". func (ac *AdminClient) Subscriptions(ctx context.Context, parent string) *SubscriptionIterator { if _, err := wire.ParseLocationPath(parent); err != nil { return &SubscriptionIterator{err: err} @@ -411,8 +413,8 @@ type TopicPathIterator struct { } // Next returns the next topic path, which has format: -// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". The -// second return value will be iterator.Done if there are no more topic paths. +// "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". The second return +// value will be iterator.Done if there are no more topic paths. func (sp *TopicPathIterator) Next() (string, error) { if sp.err != nil { return "", sp.err @@ -432,7 +434,7 @@ type SubscriptionPathIterator struct { } // Next returns the next subscription path, which has format: -// "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". The +// "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". The // second return value will be iterator.Done if there are no more subscription // paths. func (sp *SubscriptionPathIterator) Next() (string, error) { diff --git a/pubsublite/config.go b/pubsublite/config.go index 000d3929e81..7126045484d 100644 --- a/pubsublite/config.go +++ b/pubsublite/config.go @@ -34,13 +34,14 @@ const InfiniteRetention = time.Duration(-1) // about how topics are configured. type TopicConfig struct { // The full path of the topic, in the format: - // "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". + // "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". // // - PROJECT_ID: The project ID (e.g. "my-project") or the project number // (e.g. "987654321") can be provided. - // - ZONE: The Google Cloud zone (e.g. "us-central1-a") where the topic is - // located. See https://cloud.google.com/pubsub/lite/docs/locations for the - // list of zones where Pub/Sub Lite is available. + // - LOCATION: The Google Cloud region (e.g. "us-central1") or zone + // (e.g. "us-central1-a") where the topic is located. + // See https://cloud.google.com/pubsub/lite/docs/locations for the list of + // regions and zones where Pub/Sub Lite is available. // - TOPIC_ID: The ID of the topic (e.g. "my-topic"). See // https://cloud.google.com/pubsub/docs/admin#resource_names for information // about valid topic IDs. @@ -128,7 +129,7 @@ func protoToTopicConfig(t *pb.Topic) (*TopicConfig, error) { // TopicConfigToUpdate specifies the properties to update for a topic. type TopicConfigToUpdate struct { // The full path of the topic to update, in the format: - // "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". Required. + // "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". Required. Name string // If non-zero, will update the number of partitions in the topic. @@ -234,19 +235,19 @@ const ( // information about how subscriptions are configured. type SubscriptionConfig struct { // The full path of the subscription, in the format: - // "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". + // "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". // // - PROJECT_ID: The project ID (e.g. "my-project") or the project number // (e.g. "987654321") can be provided. - // - ZONE: The Google Cloud zone (e.g. "us-central1-a") of the corresponding - // topic. + // - LOCATION: The Google Cloud region (e.g. "us-central1") or zone + // (e.g. "us-central1-a") of the corresponding topic. // - SUBSCRIPTION_ID: The ID of the subscription (e.g. "my-subscription"). See // https://cloud.google.com/pubsub/docs/admin#resource_names for information // about valid subscription IDs. Name string // The path of the topic that this subscription is attached to, in the format: - // "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". This cannot be + // "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". This cannot be // changed after creation. Topic string @@ -282,7 +283,7 @@ func protoToSubscriptionConfig(s *pb.Subscription) *SubscriptionConfig { // subscription. type SubscriptionConfigToUpdate struct { // The full path of the subscription to update, in the format: - // "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". + // "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". // Required. Name string diff --git a/pubsublite/doc.go b/pubsublite/doc.go index cb714698aaa..9c84150ef2b 100644 --- a/pubsublite/doc.go +++ b/pubsublite/doc.go @@ -184,5 +184,16 @@ client that may be able to handle messages. See https://cloud.google.com/pubsub/lite/docs/subscribing for more information about receiving messages. + + +gRPC Connection Pools + +Pub/Sub Lite utilizes gRPC streams extensively. gRPC allows a maximum of 100 +streams per connection. Internally, the library uses a default connection pool +size of 8, which supports up to 800 topic partitions. To alter the connection +pool size, pass a ClientOption to pscompat.NewPublisherClient and +pscompat.NewSubscriberClient: + + pub, err := pscompat.NewPublisherClient(ctx, topicPath, option.WithGRPCConnectionPool(10)) */ package pubsublite // import "cloud.google.com/go/pubsublite" diff --git a/pubsublite/example_test.go b/pubsublite/example_test.go index bba59700bc2..17c0f73746d 100644 --- a/pubsublite/example_test.go +++ b/pubsublite/example_test.go @@ -22,14 +22,14 @@ import ( "google.golang.org/api/iterator" ) -// This example demonstrates how to create a new topic. -// See https://cloud.google.com/pubsub/lite/docs/topics for more information -// about how Pub/Sub Lite topics are configured. -// See https://cloud.google.com/pubsub/lite/docs/locations for the list of zones -// where Pub/Sub Lite is available. +// This example demonstrates how to create a new topic. Topics may be regional +// or zonal. See https://cloud.google.com/pubsub/lite/docs/topics for more +// information about how Pub/Sub Lite topics are configured. +// See https://cloud.google.com/pubsub/lite/docs/locations for the list of +// regions and zones where Pub/Sub Lite is available. func ExampleAdminClient_CreateTopic() { ctx := context.Background() - // NOTE: region must correspond to the zone of the topic. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. @@ -37,7 +37,7 @@ func ExampleAdminClient_CreateTopic() { const gib = 1 << 30 topicConfig := pubsublite.TopicConfig{ - Name: "projects/my-project/locations/zone/topics/my-topic", + Name: "projects/my-project/locations/region-or-zone/topics/my-topic", PartitionCount: 2, // Must be at least 1. PublishCapacityMiBPerSec: 4, // Must be 4-16 MiB/s. SubscribeCapacityMiBPerSec: 8, // Must be 4-32 MiB/s. @@ -53,14 +53,14 @@ func ExampleAdminClient_CreateTopic() { func ExampleAdminClient_UpdateTopic() { ctx := context.Background() - // NOTE: region must correspond to the zone of the topic. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } updateConfig := pubsublite.TopicConfigToUpdate{ - Name: "projects/my-project/locations/zone/topics/my-topic", + Name: "projects/my-project/locations/region-or-zone/topics/my-topic", PartitionCount: 3, // Only increases currently supported. PublishCapacityMiBPerSec: 8, SubscribeCapacityMiBPerSec: 16, @@ -74,13 +74,13 @@ func ExampleAdminClient_UpdateTopic() { func ExampleAdminClient_DeleteTopic() { ctx := context.Background() - // NOTE: region must correspond to the zone of the topic. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" if err := admin.DeleteTopic(ctx, topic); err != nil { // TODO: Handle error. } @@ -88,14 +88,14 @@ func ExampleAdminClient_DeleteTopic() { func ExampleAdminClient_Topics() { ctx := context.Background() - // NOTE: region must correspond to the zone below. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } - // List the configs of all topics in the given zone for the project. - it := admin.Topics(ctx, "projects/my-project/locations/zone") + // List the configs of all topics in the given region or zone for the project. + it := admin.Topics(ctx, "projects/my-project/locations/region-or-zone") for { topicConfig, err := it.Next() if err == iterator.Done { @@ -110,14 +110,14 @@ func ExampleAdminClient_Topics() { func ExampleAdminClient_TopicSubscriptions() { ctx := context.Background() - // NOTE: region must correspond to the zone of the topic. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } // List the paths of all subscriptions of a topic. - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" it := admin.TopicSubscriptions(ctx, topic) for { subscriptionPath, err := it.Next() @@ -136,15 +136,15 @@ func ExampleAdminClient_TopicSubscriptions() { // information about how subscriptions are configured. func ExampleAdminClient_CreateSubscription() { ctx := context.Background() - // NOTE: region must correspond to the zone of the topic and subscription. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } subscriptionConfig := pubsublite.SubscriptionConfig{ - Name: "projects/my-project/locations/zone/subscriptions/my-subscription", - Topic: "projects/my-project/locations/zone/topics/my-topic", + Name: "projects/my-project/locations/region-or-zone/subscriptions/my-subscription", + Topic: "projects/my-project/locations/region-or-zone/topics/my-topic", // Do not wait for a published message to be successfully written to storage // before delivering it to subscribers. DeliveryRequirement: pubsublite.DeliverImmediately, @@ -157,14 +157,14 @@ func ExampleAdminClient_CreateSubscription() { func ExampleAdminClient_UpdateSubscription() { ctx := context.Background() - // NOTE: region must correspond to the zone of the subscription. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } updateConfig := pubsublite.SubscriptionConfigToUpdate{ - Name: "projects/my-project/locations/zone/subscriptions/my-subscription", + Name: "projects/my-project/locations/region-or-zone/subscriptions/my-subscription", // Deliver a published message to subscribers after it has been successfully // written to storage. DeliveryRequirement: pubsublite.DeliverAfterStored, @@ -177,13 +177,13 @@ func ExampleAdminClient_UpdateSubscription() { func ExampleAdminClient_SeekSubscription() { ctx := context.Background() - // NOTE: region must correspond to the zone of the subscription. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" seekOp, err := admin.SeekSubscription(ctx, subscription, pubsublite.Beginning) if err != nil { // TODO: Handle error. @@ -204,13 +204,13 @@ func ExampleAdminClient_SeekSubscription() { func ExampleAdminClient_DeleteSubscription() { ctx := context.Background() - // NOTE: region must correspond to the zone of the subscription. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" if err := admin.DeleteSubscription(ctx, subscription); err != nil { // TODO: Handle error. } @@ -218,14 +218,14 @@ func ExampleAdminClient_DeleteSubscription() { func ExampleAdminClient_Subscriptions() { ctx := context.Background() - // NOTE: region must correspond to the zone below. + // NOTE: resources must be located within this region. admin, err := pubsublite.NewAdminClient(ctx, "region") if err != nil { // TODO: Handle error. } - // List the configs of all subscriptions in the given zone for the project. - it := admin.Subscriptions(ctx, "projects/my-project/locations/zone") + // List the configs of all subscriptions in the given region or zone for the project. + it := admin.Subscriptions(ctx, "projects/my-project/locations/region-or-zone") for { subscriptionConfig, err := it.Next() if err == iterator.Done { diff --git a/pubsublite/internal/wire/resources.go b/pubsublite/internal/wire/resources.go index 23621d40b78..cda60399fde 100644 --- a/pubsublite/internal/wire/resources.go +++ b/pubsublite/internal/wire/resources.go @@ -63,7 +63,7 @@ func ParseLocationPath(input string) (LocationPath, error) { parts := locPathRE.FindStringSubmatch(input) if len(parts) < 3 { return LocationPath{}, fmt.Errorf("pubsublite: invalid location path %q. valid format is %q", - input, "projects/PROJECT_ID/locations/ZONE") + input, "projects/PROJECT_ID/locations/LOCATION") } return LocationPath{Project: parts[1], Location: parts[2]}, nil } diff --git a/pubsublite/operations.go b/pubsublite/operations.go index e19a252d68b..0c69c60d01b 100644 --- a/pubsublite/operations.go +++ b/pubsublite/operations.go @@ -86,7 +86,7 @@ type SeekSubscriptionResult struct{} type OperationMetadata struct { // The target of the operation. For example, targets of seeks are // subscriptions, structured like: - // "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID" + // "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID" Target string // The verb describing the kind of operation. diff --git a/pubsublite/pscompat/example_test.go b/pubsublite/pscompat/example_test.go index 7dc32ca3b93..5321bc2ad78 100644 --- a/pubsublite/pscompat/example_test.go +++ b/pubsublite/pscompat/example_test.go @@ -27,7 +27,7 @@ import ( func ExamplePublisherClient_Publish() { ctx := context.Background() - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" publisher, err := pscompat.NewPublisherClient(ctx, topic) if err != nil { // TODO: Handle error. @@ -67,7 +67,7 @@ func ExamplePublisherClient_Publish() { // topic. func ExamplePublisherClient_Publish_batchingSettings() { ctx := context.Background() - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" settings := pscompat.PublishSettings{ DelayThreshold: 50 * time.Millisecond, CountThreshold: 200, @@ -113,7 +113,7 @@ func ExamplePublisherClient_Publish_batchingSettings() { // PublishSettings.Timeout value to detect and alert. func ExamplePublisherClient_Publish_errorHandling() { ctx := context.Background() - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" settings := pscompat.PublishSettings{ // The PublisherClient will terminate when it cannot connect to backends for // more than 10 minutes. @@ -173,7 +173,7 @@ func ExamplePublisherClient_Publish_errorHandling() { func ExampleSubscriberClient_Receive() { ctx := context.Background() - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" subscriber, err := pscompat.NewSubscriberClient(ctx, subscription) if err != nil { // TODO: Handle error. @@ -197,7 +197,7 @@ func ExampleSubscriberClient_Receive() { // ReceiveSettings.Timeout value to detect and alert. func ExampleSubscriberClient_Receive_errorHandling() { ctx := context.Background() - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" settings := pscompat.ReceiveSettings{ // The SubscriberClient will terminate when it cannot connect to backends // for more than 5 minutes. @@ -238,7 +238,7 @@ func ExampleSubscriberClient_Receive_errorHandling() { // partitions in the associated topic. func ExampleSubscriberClient_Receive_maxOutstanding() { ctx := context.Background() - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" settings := pscompat.ReceiveSettings{ MaxOutstandingMessages: 5, MaxOutstandingBytes: 10e6, @@ -268,7 +268,7 @@ func ExampleSubscriberClient_Receive_maxOutstanding() { // determine which partitions it should connect to. func ExampleSubscriberClient_Receive_manualPartitionAssignment() { ctx := context.Background() - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" settings := pscompat.ReceiveSettings{ // NOTE: The corresponding topic must have 2 or more partitions. Partitions: []int{0, 1}, @@ -310,7 +310,7 @@ func ExampleNewPublisherClient_interface() { // Create a Pub/Sub Lite publisher client. ctx := context.Background() - publisher, err := pscompat.NewPublisherClient(ctx, "projects/my-project/locations/zone/topics/my-topic") + publisher, err := pscompat.NewPublisherClient(ctx, "projects/my-project/locations/region-or-zone/topics/my-topic") if err != nil { // TODO: Handle error. } @@ -341,7 +341,7 @@ func ExampleNewSubscriberClient_interface() { // Create a Pub/Sub Lite subscriber client. ctx := context.Background() - subscriber, err := pscompat.NewSubscriberClient(ctx, "projects/my-project/locations/zone/subscriptions/my-subscription") + subscriber, err := pscompat.NewSubscriberClient(ctx, "projects/my-project/locations/region-or-zone/subscriptions/my-subscription") if err != nil { // TODO: Handle error. } @@ -358,7 +358,7 @@ func ExampleNewSubscriberClient_interface() { func ExampleParseMessageMetadata_publisher() { ctx := context.Background() - const topic = "projects/my-project/locations/zone/topics/my-topic" + const topic = "projects/my-project/locations/region-or-zone/topics/my-topic" publisher, err := pscompat.NewPublisherClient(ctx, topic) if err != nil { // TODO: Handle error. @@ -379,7 +379,7 @@ func ExampleParseMessageMetadata_publisher() { func ExampleParseMessageMetadata_subscriber() { ctx := context.Background() - const subscription = "projects/my-project/locations/zone/subscriptions/my-subscription" + const subscription = "projects/my-project/locations/region-or-zone/subscriptions/my-subscription" subscriber, err := pscompat.NewSubscriberClient(ctx, subscription) if err != nil { // TODO: Handle error. diff --git a/pubsublite/pscompat/publisher.go b/pubsublite/pscompat/publisher.go index bc68a677bb1..41d9fea8580 100644 --- a/pubsublite/pscompat/publisher.go +++ b/pubsublite/pscompat/publisher.go @@ -63,7 +63,7 @@ type PublisherClient struct { // NewPublisherClient creates a new Pub/Sub Lite publisher client to publish // messages to a given topic, using DefaultPublishSettings. A valid topic path -// has the format: "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// has the format: "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func NewPublisherClient(ctx context.Context, topic string, opts ...option.ClientOption) (*PublisherClient, error) { return NewPublisherClientWithSettings(ctx, topic, DefaultPublishSettings, opts...) } @@ -71,7 +71,7 @@ func NewPublisherClient(ctx context.Context, topic string, opts ...option.Client // NewPublisherClientWithSettings creates a new Pub/Sub Lite publisher client to // publish messages to a given topic, using the specified PublishSettings. A // valid topic path has the format: -// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID". +// "projects/PROJECT_ID/locations/LOCATION/topics/TOPIC_ID". func NewPublisherClientWithSettings(ctx context.Context, topic string, settings PublishSettings, opts ...option.ClientOption) (*PublisherClient, error) { topicPath, err := wire.ParseTopicPath(topic) if err != nil { diff --git a/pubsublite/pscompat/subscriber.go b/pubsublite/pscompat/subscriber.go index d0d00e0a3f1..5a9272378af 100644 --- a/pubsublite/pscompat/subscriber.go +++ b/pubsublite/pscompat/subscriber.go @@ -256,7 +256,7 @@ type SubscriberClient struct { // NewSubscriberClient creates a new Pub/Sub Lite client to receive messages for // a given subscription, using DefaultReceiveSettings. A valid subscription path // has the format: -// "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". +// "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". func NewSubscriberClient(ctx context.Context, subscription string, opts ...option.ClientOption) (*SubscriberClient, error) { return NewSubscriberClientWithSettings(ctx, subscription, DefaultReceiveSettings, opts...) } @@ -264,7 +264,7 @@ func NewSubscriberClient(ctx context.Context, subscription string, opts ...optio // NewSubscriberClientWithSettings creates a new Pub/Sub Lite client to receive // messages for a given subscription, using the specified ReceiveSettings. A // valid subscription path has the format: -// "projects/PROJECT_ID/locations/ZONE/subscriptions/SUBSCRIPTION_ID". +// "projects/PROJECT_ID/locations/LOCATION/subscriptions/SUBSCRIPTION_ID". func NewSubscriberClientWithSettings(ctx context.Context, subscription string, settings ReceiveSettings, opts ...option.ClientOption) (*SubscriberClient, error) { subscriptionPath, err := wire.ParseSubscriptionPath(subscription) if err != nil {