forked from foxis/EasyRobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
58 lines (50 loc) · 1.06 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package nats
import (
"github.com/itohio/EasyRobot/pkg/core/options"
"github.com/itohio/EasyRobot/pkg/core/plugin"
"github.com/itohio/EasyRobot/pkg/core/store"
)
const NAME = "nats"
type Options struct {
base plugin.Options
urls string
creds string
topicPub string
topicSub string
keys []store.FQDNType
}
func WithUrls(urls string) options.Option {
return func(o interface{}) {
if opt, ok := o.(*Options); ok {
opt.urls = urls
}
}
}
func WithCredentials(creds string) options.Option {
return func(o interface{}) {
if opt, ok := o.(*Options); ok {
opt.creds = creds
}
}
}
func WithSubscribe(topic string) options.Option {
return func(o interface{}) {
if opt, ok := o.(*Options); ok {
opt.topicSub = topic
}
}
}
func WithPublish(topic string) options.Option {
return func(o interface{}) {
if opt, ok := o.(*Options); ok {
opt.topicSub = topic
}
}
}
func WithKeys(key ...store.FQDNType) options.Option {
return func(o interface{}) {
if opt, ok := o.(*Options); ok {
opt.keys = append(opt.keys, key...)
}
}
}