Skip to content

Commit 40538c3

Browse files
authored
docs(pubsub): update migration docs with seek (googleapis#12642)
1 parent ddfc6fd commit 40538c3

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

pubsub/MIGRATING.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ The following is an overview of the migration process. You can find more details
3636

3737
## Admin operations
3838

39-
The Pub/Sub admin plane is used to manage Pub/Sub resources like topics, subscriptions, and schemas. These admin operations include `Create`, `Get`, `Update`, `List`, and `Delete`.
39+
The Pub/Sub admin plane is used to manage Pub/Sub resources like topics, subscriptions, and schemas. These admin operations include `Create`, `Get`, `Update`, `List`, and `Delete`. For subscriptions, seek and snapshots are also part of this layer.
4040

4141
One of the key differences between the v1 and v2 versions is the change to the admin API. Two new clients called `TopicAdminClient` and `SubscriptionAdminClient` are added that handle the admin operations for topics and subscriptions respectively.
4242

4343
For topics and subscriptions, you can access these admin clients as fields of the main client: `pubsub.Client.TopicAdminClient` and `pubsub.Client.SubscriptionAdminClient`. These clients are pre-initialized when calling `pubsub.NewClient`, and takes in the same `ClientOptions` when `NewClient` is called.
4444

45-
There is a mostly one-to-one mapping of existing admin methods to the new admin methods.
45+
There is a mostly one-to-one mapping of existing admin methods to the new admin methods. There are some exceptions that are noted below.
4646

4747
### General RPCs
4848

@@ -344,6 +344,34 @@ topic, err := client.TopicAdminClient.CreateTopic(ctx, topicpb)
344344

345345
In this case, `MessageTransform_JavascriptUdf` satisfies the interface, while `JavascriptUdf` holds the actual strings relevant for the message transform.
346346

347+
### Seek / snapshots
348+
349+
Seek and snapshot RPCs are also part of the admin layer. Use the [SubscriptionAdminClient](https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1#SubscriptionAdminClient) to Seek to specific time or snapshot.
350+
351+
```go
352+
// v2 way to call seek on a subscription
353+
354+
import (
355+
"cloud.google.com/go/pubsub/v2"
356+
"google.golang.org/protobuf/types/known/timestamppb"
357+
pb "cloud.google.com/go/pubsub/v2/apiv1/pubsubpb"
358+
)
359+
...
360+
projectID := "my-project-id"
361+
subscriptionID := "my-subscription-id"
362+
363+
now := time.Now()
364+
365+
client, err := pubsub.NewClient(ctx, projectID)
366+
...
367+
client.SubscriptionAdminClient.Seek(ctx, &pb.SeekRequest{
368+
Subscription: fmt.Sprintf("projects/%s/subscriptions/%s", projectID, subID),
369+
Target: &pb.SeekRequest_Time{
370+
Time: timestamppb.New(now),
371+
},
372+
})
373+
```
374+
347375
### Call Options (retries and timeouts)
348376

349377
In the v2, [pubsub.NewClientWithConfig](https://pkg.go.dev/cloud.google.com/go/pubsub#NewClientWithConfig) is still the correct method to invoke to add RPC specific retries and timeouts. However, the helper struct is renamed from `ClientConfig.PublisherCallOptions` to `TopicAdminCallOptions`. The same is true for Subscription calls, which is now named `SubscriptionAdminCallOptions.`

0 commit comments

Comments
 (0)