-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic_gcp.go
46 lines (36 loc) · 923 Bytes
/
topic_gcp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cloud_pubsub
import (
"cloud.google.com/go/pubsub"
"context"
)
type (
topicFactory func(string) (topic, error)
topic interface {
ID() string
Stop()
Publish(ctx context.Context, msg *pubsub.Message) publishResult
PublishSettings() pubsub.PublishSettings
SetPublishSettings(settings pubsub.PublishSettings)
}
publishResult interface {
Get(ctx context.Context) (string, error)
}
topicWrapper struct {
topic *pubsub.Topic
}
)
func (tw *topicWrapper) ID() string {
return tw.topic.ID()
}
func (tw *topicWrapper) Stop() {
tw.topic.Stop()
}
func (tw *topicWrapper) Publish(ctx context.Context, msg *pubsub.Message) publishResult {
return tw.topic.Publish(ctx, msg)
}
func (tw *topicWrapper) PublishSettings() pubsub.PublishSettings {
return tw.topic.PublishSettings
}
func (tw *topicWrapper) SetPublishSettings(settings pubsub.PublishSettings) {
tw.topic.PublishSettings = settings
}