Chromium Code Reviews| Index: client/internal/logdog/butler/output/pubsub/pubsubOutput.go |
| diff --git a/client/internal/logdog/butler/output/pubsub/pubsubOutput.go b/client/internal/logdog/butler/output/pubsub/pubsubOutput.go |
| index cda2070f6b9ffa64ff19bb07a9286d52283fe77d..4910196b8ba744a7f14f15fb5e796f747c4f5857 100644 |
| --- a/client/internal/logdog/butler/output/pubsub/pubsubOutput.go |
| +++ b/client/internal/logdog/butler/output/pubsub/pubsubOutput.go |
| @@ -22,10 +22,20 @@ import ( |
| "google.golang.org/cloud/pubsub" |
| ) |
| +// Publisher is an interface for something that publishes Pub/Sub messages. |
|
dnj (Google)
2016/01/21 04:36:24
Make a specific interface instead of requiring one
|
| +// |
| +// gcps.PubSub implements this interface. |
| +type Publisher interface { |
| + // Publish mirrors the gcps.PubSub Publish method. |
| + Publish(context.Context, gcps.Topic, ...*pubsub.Message) ([]string, error) |
| +} |
| + |
| +var _ Publisher = gcps.PubSub(nil) |
| + |
| // Config is a configuration structure for GCPS output. |
| type Config struct { |
| - // Pubsub is the Pub/Sub instance to use. |
| - PubSub gcps.PubSub |
| + // Publisher is the Pub/Sub instance to use. |
| + Publisher Publisher |
| // Topic is the name of the Cloud Pub/Sub topic to publish to. |
| Topic gcps.Topic |
| @@ -36,7 +46,7 @@ type Config struct { |
| // Validate validates the Output configuration. |
| func (c *Config) Validate() error { |
| - if c.PubSub == nil { |
| + if c.Publisher == nil { |
| return errors.New("gcps: no pub/sub instance configured") |
| } |
| if err := c.Topic.Validate(); err != nil { |
| @@ -165,7 +175,7 @@ func (o *gcpsOutput) publishMessages(messages []*pubsub.Message) error { |
| var messageIDs []string |
| count := 0 |
| err := retry.Retry(o, retry.TransientOnly(retry.Default()), func() error { |
| - ids, err := o.PubSub.Publish(o.Topic, messages...) |
| + ids, err := o.Publisher.Publish(o, o.Topic, messages...) |
| if err != nil { |
| return err |
| } |