Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package gcps | 5 package gcps |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "golang.org/x/net/context" | |
| 8 "google.golang.org/cloud/pubsub" | 9 "google.golang.org/cloud/pubsub" |
| 9 ) | 10 ) |
| 10 | 11 |
| 11 var ( | 12 var ( |
| 12 // PublisherScopes is the set of OAuth2 scopes needed for a publisher to | 13 // PublisherScopes is the set of OAuth2 scopes needed for a publisher to |
| 13 // publish messages. | 14 // publish messages. |
| 14 PublisherScopes = []string{ | 15 PublisherScopes = []string{ |
| 15 pubsub.ScopePubSub, | 16 pubsub.ScopePubSub, |
| 16 } | 17 } |
| 17 | 18 |
| 18 // SubscriberScopes is the set of OAuth2 scopes needed for a subscriber to | 19 // SubscriberScopes is the set of OAuth2 scopes needed for a subscriber to |
| 19 // pull and acknowledge messages. | 20 // pull and acknowledge messages. |
| 20 SubscriberScopes = []string{ | 21 SubscriberScopes = []string{ |
| 21 pubsub.ScopePubSub, | 22 pubsub.ScopePubSub, |
| 22 } | 23 } |
| 23 ) | 24 ) |
| 24 | 25 |
| 25 // PubSub is an interface around Pub/Sub functionality. | 26 // PubSub is an interface around Pub/Sub functionality. |
| 26 // | 27 // |
| 27 // Any method may return an errors.TransientError to indicate that the | 28 // Any method may return an errors.TransientError to indicate that the |
| 28 // encountered error was transient. | 29 // encountered error was transient. |
| 29 type PubSub interface { | 30 type PubSub interface { |
| 30 // TopicExists tests if a given Topic exists. | 31 // TopicExists tests if a given Topic exists. |
| 31 » TopicExists(Topic) (bool, error) | 32 » TopicExists(context.Context, Topic) (bool, error) |
|
dnj (Google)
2016/01/21 04:36:24
All methods take context.Context now. This is beca
| |
| 32 | 33 |
| 33 // SubscriptionExists tests if a given Subscription exists. | 34 // SubscriptionExists tests if a given Subscription exists. |
| 34 » SubExists(Subscription) (bool, error) | 35 » SubExists(context.Context, Subscription) (bool, error) |
| 35 | 36 |
| 36 // Publish publishes a batch of Pub/Sub messages. | 37 // Publish publishes a batch of Pub/Sub messages. |
| 37 » Publish(Topic, ...*pubsub.Message) ([]string, error) | 38 » Publish(context.Context, Topic, ...*pubsub.Message) ([]string, error) |
| 38 | 39 |
| 39 // Pull pulls messages from the subscription. It returns up the requeste d | 40 // Pull pulls messages from the subscription. It returns up the requeste d |
| 40 // number of messages. | 41 // number of messages. |
| 41 » Pull(Subscription, int) ([]*pubsub.Message, error) | 42 » Pull(context.Context, Subscription, int) ([]*pubsub.Message, error) |
| 42 | 43 |
| 43 // Ack acknowledges one or more Pub/Sub message ACK IDs. | 44 // Ack acknowledges one or more Pub/Sub message ACK IDs. |
| 44 » Ack(Subscription, ...string) error | 45 » Ack(context.Context, Subscription, ...string) error |
| 45 } | 46 } |
| OLD | NEW |