()
| 74 | } |
| 75 | |
| 76 | func ExampleOpenSubscription() { |
| 77 | // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored. |
| 78 | // PRAGMA: On gocloud.dev, hide lines until the next blank line. |
| 79 | ctx := context.Background() |
| 80 | |
| 81 | // Your GCP credentials. |
| 82 | // See https://cloud.google.com/docs/authentication/production |
| 83 | // for more info on alternatives. |
| 84 | creds, err := gcp.DefaultCredentials(ctx) |
| 85 | if err != nil { |
| 86 | log.Fatal(err) |
| 87 | } |
| 88 | |
| 89 | // Open a gRPC connection to the GCP Pub/Sub API. |
| 90 | conn, cleanup, err := gcppubsub.Dial(ctx, creds.TokenSource) |
| 91 | if err != nil { |
| 92 | log.Fatal(err) |
| 93 | } |
| 94 | defer cleanup() |
| 95 | |
| 96 | // Construct a SubscriberClient using the connection. |
| 97 | subClient, err := gcppubsub.SubscriberClient(ctx, conn) |
| 98 | if err != nil { |
| 99 | log.Fatal(err) |
| 100 | } |
| 101 | defer subClient.Close() |
| 102 | |
| 103 | // Construct a *pubsub.Subscription. |
| 104 | subscription, err := gcppubsub.OpenSubscriptionByPath( |
| 105 | subClient, "projects/myprojectID/subscriptions/example-subscription", nil) |
| 106 | if err != nil { |
| 107 | log.Fatal(err) |
| 108 | } |
| 109 | defer subscription.Shutdown(ctx) |
| 110 | } |
| 111 | |
| 112 | func Example_extendingAckDeadline() { |
| 113 | ctx := context.Background() |
nothing calls this directly
no test coverage detected