forked from st3v/go-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
32 lines (27 loc) · 796 Bytes
/
options.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
package googlepubsub
import (
"github.com/micro/go-micro/broker"
"golang.org/x/net/context"
"google.golang.org/api/option"
)
type clientOptionKey struct{}
type projectIDKey struct{}
// ClientOption is a broker Option which allows google pubsub client options to be
// set for the client
func ClientOption(c ...option.ClientOption) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, clientOptionKey{}, c)
}
}
// ProjectID provides an option which sets the google project id
func ProjectID(id string) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, projectIDKey{}, id)
}
}