-
Notifications
You must be signed in to change notification settings - Fork 25
/
options.go
42 lines (33 loc) · 984 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
33
34
35
36
37
38
39
40
41
42
package servicecfg
import (
"github.com/xmidt-org/webpa-common/service"
"github.com/xmidt-org/webpa-common/service/consul"
"github.com/xmidt-org/webpa-common/service/zk"
)
// Options contains the superset of all necessary options for initializing service discovery.
type Options struct {
VnodeCount int `json:"vnodeCount,omitempty"`
DisableFilter bool `json:"disableFilter"`
DefaultScheme string `json:"defaultScheme"`
Fixed []string `json:"fixed,omitempty"`
Zookeeper *zk.Options `json:"zookeeper,omitempty"`
Consul *consul.Options `json:"consul,omitempty"`
}
func (o *Options) vnodeCount() int {
if o != nil && o.VnodeCount > 0 {
return o.VnodeCount
}
return service.DefaultVnodeCount
}
func (o *Options) disableFilter() bool {
if o != nil {
return o.DisableFilter
}
return false
}
func (o *Options) defaultScheme() string {
if o != nil && len(o.DefaultScheme) > 0 {
return o.DefaultScheme
}
return service.DefaultScheme
}